Skip to content

Add 404 for Analytics.upsert_analytics_rule#47

Merged
jaeyson merged 2 commits intomainfrom
45-add-404-for-upsert-analytics-rule
Apr 14, 2026
Merged

Add 404 for Analytics.upsert_analytics_rule#47
jaeyson merged 2 commits intomainfrom
45-add-404-for-upsert-analytics-rule

Conversation

@jaeyson
Copy link
Copy Markdown
Owner

@jaeyson jaeyson commented Apr 14, 2026

Summary by Sourcery

Document 404 Not Found responses for analytics rule updates and align the analytics operation response types accordingly.

Bug Fixes:

  • Handle missing analytics rules in the upsert analytics rule operation with a 404 ApiResponse.

Documentation:

  • Add 404 Not Found response documentation for the analytics rule upsert endpoint in the OpenAPI spec.

@jaeyson jaeyson self-assigned this Apr 14, 2026
@jaeyson jaeyson added the bug Something isn't working label Apr 14, 2026
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 14, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the Analytics.upsert_analytics_rule endpoint to document and handle a 404 "not found" response consistently across the OpenAPI spec and Elixir client operation definition.

Sequence diagram for Analytics.upsert_analytics_rule 404 handling

sequenceDiagram
  actor Client
  participant AnalyticsClient as OpenApiTypesense_Analytics
  participant TypesenseAPI as Typesense_Analytics_Endpoint

  Client->>AnalyticsClient: upsert_analytics_rule(rule_id, payload, opts)
  AnalyticsClient->>TypesenseAPI: HTTP PUT /analytics/rules/{rule_id}
  TypesenseAPI-->>AnalyticsClient: 404 ApiResponse
  AnalyticsClient-->>Client: {:error, ApiResponse} for 404
Loading

Updated class diagram for Analytics.upsert_analytics_rule responses

classDiagram
  class OpenApiTypesense_Analytics {
    +upsert_analytics_rule(rule_id, payload, opts)
  }

  class OpenApiTypesense_AnalyticsRule {
    +id
    +params
  }

  class OpenApiTypesense_ApiResponse {
    +status_code
    +message
    +errors
  }

  OpenApiTypesense_Analytics ..> OpenApiTypesense_AnalyticsRule : returns_200
  OpenApiTypesense_Analytics ..> OpenApiTypesense_ApiResponse : returns_400
  OpenApiTypesense_Analytics ..> OpenApiTypesense_ApiResponse : returns_401
  OpenApiTypesense_Analytics ..> OpenApiTypesense_ApiResponse : returns_404
Loading

File-Level Changes

Change Details Files
Document 404 response for upserting an analytics rule in the OpenAPI schema.
  • Add a 404 response entry to the analytics rule upsert endpoint in the OpenAPI YAML
  • Reuse the existing generic ApiResponse schema for the 404 response payload
priv/open_api.yml
Expose 404 as a typed response for Analytics.upsert_analytics_rule in the Elixir OpenApiTypesense client.
  • Extend the response tuple list for the upsert_analytics_rule operation to include a 404 mapped to ApiResponse
  • Keep existing 200, 400, and 401 responses unchanged
lib/open_api_typesense/operations/analytics.ex

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="lib/open_api_typesense/operations/analytics.ex" line_range="310" />
<code_context>
         {400, {OpenApiTypesense.ApiResponse, :t}},
-        {401, {OpenApiTypesense.ApiResponse, :t}}
+        {401, {OpenApiTypesense.ApiResponse, :t}},
+        {404, {OpenApiTypesense.ApiResponse, :t}}
       ],
       opts: opts
</code_context>
<issue_to_address>
**issue:** Check that callers pattern-matching on responses are updated to handle the new 404 case explicitly

This new 404 variant changes the response type for this operation. Please review any downstream pattern matches or case clauses that assumed only 200/400/401 to ensure 404 is handled explicitly rather than falling into a generic catch-all.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

Copy link
Copy Markdown

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gates Passed
3 Quality Gates Passed

See analysis details in CodeScene

Absence of Expected Change Pattern

  • open_api_typesense/lib/open_api_typesense/operations/analytics.ex is usually changed with: open_api_typesense/lib/open_api_typesense/operations/debug.ex, open_api_typesense/lib/open_api_typesense/operations/collections.ex, open_api_typesense/lib/open_api_typesense/operations/operations.ex, open_api_typesense/lib/open_api_typesense/operations/synonyms.ex, open_api_typesense/lib/open_api_typesense/operations/override.ex, open_api_typesense/lib/open_api_typesense/operations/presets.ex, open_api_typesense/lib/open_api_typesense/operations/curation.ex, open_api_typesense/lib/open_api_typesense/operations/conversations.ex

Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@jaeyson jaeyson merged commit 8817fd8 into main Apr 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant