Skip to content

fix(analytics): catch InfluxDBError in influx_query_manager (fixes #8510) - #8577

Open
siddiqueirshad wants to merge 2 commits into
Flagsmith:mainfrom
siddiqueirshad:fix/influx-query-manager-catch-api-exception
Open

siddiqueirshad wants to merge 2 commits into
Flagsmith:mainfrom
siddiqueirshad:fix/influx-query-manager-catch-api-exception

Conversation

@siddiqueirshad

Copy link
Copy Markdown

Fixes #8510

Cause

influx_query_manager caught only urllib3.exceptions.HTTPError, which covers network/socket connection errors but not Influx HTTP error responses (influxdb_client.client.exceptions.InfluxDBError / ApiException). As a result, non-200 responses from InfluxDB propagated uncaught exceptions and resulted in 500 responses on caller endpoints.

Solution

  1. Catch (HTTPError, InfluxDBError) in influx_query_manager (matching write()).
  2. Add a unit test verifying influx_query_manager handles InfluxDBError by capturing the exception and returning an empty list.

@siddiqueirshad
siddiqueirshad requested a review from a team as a code owner September 23, 2026 08:10
@siddiqueirshad
siddiqueirshad requested review from emyller and removed request for a team September 23, 2026 08:10
@vercel

vercel Bot commented Sep 23, 2026

Copy link
Copy Markdown

@siddiqueirshad is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the api Issue related to the REST API label Sep 23, 2026
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 835b2a18-884c-4d30-aa84-c064f048c59e

📥 Commits

Reviewing files that changed from the base of the PR and between 5ce9709 and 19dd862.


📒 Files selected for processing (2)
  • api/app_analytics/influxdb_wrapper.py
  • api/tests/unit/app_analytics/test_unit_app_analytics_influxdb_wrapper.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.



📝 Walkthrough

Walkthrough

influx_query_manager now catches ApiException as well as HTTPError and InfluxDBError. It captures each exception and returns an empty list. Unit tests check handling of InfluxDBError and ApiException.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Severity of issue fixed: Medium


Merge Risk: ⚪ Minimal · up to 19dd8

The query manager now captures InfluxDB HTTP-response errors and returns the existing empty-result fallback, so no material merge risk remains.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 23414984-53c8-47ad-b70b-954fa7ff3e49

📥 Commits

Reviewing files that changed from the base of the PR and between abcb31c and 5ce9709.

📒 Files selected for processing (2)
  • api/app_analytics/influxdb_wrapper.py
  • api/tests/unit/app_analytics/test_unit_app_analytics_influxdb_wrapper.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread api/app_analytics/influxdb_wrapper.py
@siddiqueirshad

Copy link
Copy Markdown
Author

Updated \InfluxDBWrapper.influx_query_manager\ to also catch \influxdb_client.rest.ApiException\ in addition to \HTTPError\ and \InfluxDBError\ so InfluxDB HTTP response errors (400, 401, 429, 5xx) don't escape unhandled. Added accompanying unit test covering \ApiException.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

influx_query_manager doesn't catch ApiException, so Influx error responses 500

1 participant