fix(app-shell): unwrap the declared response envelope on the datasource page and the api-action runner (objectstack#3843) - #2972
Merged
Conversation
…ce page and the api-action runner (objectstack#3843)
framework#3843 moves four more route modules onto BaseResponseSchema, so
/api/v1/datasources/*, /api/v1/packages/* and /api/settings/* now answer
{ success, data } / { success: false, error: { code, message } }.
Two consumers here were not envelope-aware:
DatasourceResourcePage — its shared api() helper returned the raw body, so
all nine payload reads (data.datasources, data.drivers, data.tables,
{ draft }, …) would have gone undefined, and its error path did
`body.message || body.error` — which stringifies the new nested error object
to "[object Object]".
MetadataTypeActions — the generic `type: 'api'` action runner. Same
"[object Object]" on any nested error, plus a resultDialog would have bound
its `path` fields against the envelope wrapper instead of the payload.
Both now unwrap `{ success, data }` centrally and read error.message. The
packages readers needed no change: parsePackages, apiJson and
fetchFullPackage were already tolerant (`payload?.data ?? payload`).
Both shapes are accepted on purpose. The framework converts these modules one
at a time (#3675 → #3689 → #3843), so a console build must talk to a backend
on either side of that sequence — the same tolerance the attachment openers
carry for #3689. It is a migration device, not a second contract; the producer
stays the authority.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYbS3kS8xzsHNXFTzp4e2z
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
os-zhuang
marked this pull request as ready for review
July 30, 2026 01:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Console side of objectstack-ai/objectstack#3843 (framework PR: objectstack-ai/objectstack#3972).
That change moves four more route modules onto
BaseResponseSchema, so/api/v1/datasources/*,/api/v1/packages/*and/api/settings/*now answer{ success, data }/{ success: false, error: { code, message } }.What needed fixing
Two consumers here were not envelope-aware:
DatasourceResourcePage— its sharedapi()helper returned the raw body, so all nine payload reads (data.datasources,data.drivers,data.tables,{ draft }, …) would have goneundefinedand the page would have rendered empty. Its error path didbody.message || body.error, which stringifies the new nested error object to"[object Object]".MetadataTypeActions— the generictype: 'api'action runner, so this affects every declared API action, not just the datasource ones. Same"[object Object]"on any nested error, plus aresultDialogwould have bound itspathfields against the envelope wrapper instead of the payload.Both now unwrap
{ success, data }centrally — one change each rather than per-call-site, since the payload keys did not change, only their depth.What did not need fixing
The
packagesreaders were already tolerant:parsePackages,PackagesPage'sapiJson, andStudioDesignSurface.fetchFullPackageall dopayload?.data ?? payload, andapiJsonalready readpayload?.error?.messagefirst./api/settings/*has no consumer in this repo.Both shapes accepted, on purpose
The framework converts these modules one at a time (#3675 → #3689 → #3843), and a console build ships independently of the server it talks to — so this repo must not be coupled to the merge order of that sequence. Same tolerance the attachment openers already carry for #3689 (
body?.url ?? body?.data?.url). It is a migration device, not a second contract; the producer stays the authority (framework Prime Directive #12).Tests
Three new cases in
MetadataTypeActions.test.tsxpin all three directions: an enveloped success unwrapsdatabefore the result dialog binds it, an enveloped error toastserror.messageand never"[object Object]", and a pre-envelope bare-string error still resolves.app-shell: 1938 passed (235 files). Lint clean — the two remaining warnings onDatasourceResourcePageare on pre-existing lines this diff does not touch (verified against the hunk ranges).DatasourceResourcePage.tsxhas no test file of its own, so its change rests on the shared-helper reasoning plus the action-runner coverage above.Generated by Claude Code