Repository navigation
fix(api): query routes report a failed settings read as the retryable warehouse outage - #1833
Conversation
… warehouse outage Every warehouse query resolves the org's saved ClickHouse settings first. When that Postgres read failed, data pages showed "couldn't load or save this organization's data connection settings", a settings-page message users cannot act on there. resolveRoute now remaps the persistence error to WarehouseUpstreamError (503 warehouse_unavailable, retryable); encryption and invalid-config errors still pass through, and the settings endpoints keep clickhouse_settings_unavailable. v2 contract: 33 query routes stop declaring OrgClickHouseSettingsPersistenceError (all already declared WarehouseUpstreamError). The iOS openapi.json is regenerated.
Maple review🟢 Confidence 9/10 · safe to merge A failed org-settings read during route resolution now surfaces as the retryable
What was checked
|
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Map settings persistence failures packages/backend/src/services/org/OrgClickHouseSettingsService.test.ts, packages/backend/src/services/warehouse/WarehouseQueryService.ts, packages/backend/src/services/warehouse/WarehouseQueryService.test.ts |
WarehouseQueryService wraps settings persistence failures in WarehouseUpstreamError for raw and compiled queries, retaining the original error as the cause. Tests also cover persistence errors from settings get and delete. |
Update HTTP error contracts packages/domain/src/http/warehouse-errors.ts, apps/api/src/routes/v2/phase1-resources.http.test.ts, packages/domain/src/http/v2/openapi.test.ts, apps/ios/Packages/MapleAPI/Sources/MapleAPI/openapi.json |
The settings-route error type and HTTP test expectations use WarehouseUpstreamError. The OpenAPI test checks for that 503 error, and 18 endpoint descriptions no longer list OrgClickHouseSettingsPersistenceError. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Possibly related PRs
- MapleTechLabs/maple#1814: Updates the presentation of
OrgClickHouseSettingsPersistenceError, which this change remaps for warehouse query routes.
Suggested reviewers: jeremyfunk
Merge Risk: 
Minimal · up to 4b34c
-
The settings-read failure is reported as a retryable warehouse outage without exposing its internal detail. No identified issue prevents merging after normal checks.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 6 files. (1 skipped: 1 unsupported.)
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
Data pages (Services, Traces, Logs, Replays and others) said "Data connection settings temporarily unavailable. Maple couldn't load or save this organization's data connection settings." whenever the org's saved ClickHouse settings could not be read from Postgres. That message belongs to the Settings page. On a read-only data page the user can do nothing with it, and the design-pass judges flagged it repeatedly (#1826 to #1832).
Change
Every warehouse query resolves the org's saved settings first (
WarehouseQueryService.resolveRoute). A failed settings read there is now remapped withcatchTagto the existingWarehouseUpstreamError: 503,warehouse_unavailable, retryable, "Database is temporarily unavailable". The error is redacted, so the API returns its public message ("The query backend is unreachable. Retry in a few seconds."); the internal detail stays in the cause and the logs.readandrawqueries both go through this path.ingestnever reads settings.OrgClickHouseSettingsEncryptionErrorandOrgClickHouseSettingsStoredConfigInvalidErrorstill pass through: they are actionable (reconnect, contact support), not transient./internal/org-clickhouse-settings) keepclickhouse_settings_unavailableand their existing copy.v2 contract
OrgClickHouseSettingsPersistenceErroron 503. All of them already declaredWarehouseUpstreamError, and no route declares the same error twice.apps/ios/.../openapi.jsonis regenerated withbun scripts/generate-ios-openapi.ts. Its diff only drops the persistence error from 18 response descriptions.clickhouse_settings_unavailablefrom query routes now getwarehouse_unavailable. That is the retryable outage code they already handle.Verification
WarehouseQueryService.test.tsgains a test that bothcompiledQueryandrawSqlQueryturn a settings persistence failure intoWarehouseUpstreamError, with the original error ascause. Encryption and invalid-config errors still pass through as before. Together withOrgClickHouseSettingsService.test.ts, that is 96 tests.OrgClickHouseSettingsService.test.tsgains a test thatgetanddeletestill fail withOrgClickHouseSettingsPersistenceError(the settings page path).phase1-resources.http.test.ts(34 tests) checks thatGET /v2/error_issuesanswers 503warehouse_unavailable, retryable, without leaking the internal message.openapi.test.ts(274 tests insrc/http) checks that the read routes declareWarehouseUpstreamErrorand not the persistence error.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit