Repository navigation
fix: MKT-19619 appSdk.api() drops body/status text/headers on 4xx/5xx - #190
Open
amit-kanswal-cs wants to merge 3 commits into
Open
amit-kanswal-cs wants to merge 3 commits into
amit-kanswal-cs wants to merge 3 commits into
Conversation
…() errors
appSdk.api() returned `body: null`, `statusText: "Internal Server Error"`
and the *request* headers for every 4xx/5xx proxied through the platform.
The host resolves the `apiAdapter` channel with the upstream AxiosResponse
for HTTP errors; dispatchAdapter then rejected `{ ...response, config }`,
a flat object with no `response` key, so dispatchApiRequest's
`err.response` branch never ran and the transport-error fallback built the
Response from fields that do not exist on that object.
Changes
- dispatchAdapter: for HTTP errors also nest the reply under `response`.
The flat keys (status, data, headers) are kept so createAdapter()
consumers are unaffected. Transport errors ({ status, message, stack })
are rejected unchanged.
- dispatchApiRequest: convert `err.response` with axiosToFetchResponse so
object bodies are JSON-encoded instead of "[object Object]"; guard
`err.config?.headers` on the fallback.
- axiosToFetchResponse: build headers from the *response* headers instead
of the request config (apps could not read response headers even on
success); drop set-cookie and authorization.
- Tests: new __test__/adapter.test.ts drives dispatchApiRequest and
dispatchAdapter through a mocked post-robot (200, 404 JSON/string,
500 text, host 502 transport shape, post-robot failure, header
pass-through and stripping). Jest 27 has no fetch globals, so a tiny
custom environment copies Node's Response/Headers/Blob into the sandbox.
9 of the 14 new cases fail on develop and pass with this change.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
- Upgrade axios ^1.7.9 -> ^1.20.0 (lock 1.12.2 -> 1.20.0). Snyk flagged 37 issues in axios@1.12.2 and its transitive form-data@4.0.4 / follow-redirects@1.15.9; 1.20.0 is the version Snyk recommends and pulls form-data 4.0.6 and follow-redirects 1.16.1. `npm audit --omit=dev`: 0. - LICENSE: copyright range 2022-2025 -> 2022-2026 (policy-scan requires the current year). Both checks were already failing on develop; no source change. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
aniket-shikhare-cstk
previously approved these changes
Oct 23, 2026
Minor bump: api() now returns the backend body, status text and response headers on 4xx/5xx and exposes response headers on success; createAdapter() rejections gain a nested `response` key (additive). Last published is 2.4.1. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
Fixes MKT-19619:
appSdk.api()returnedbody: null,statusText: "Internal Server Error"and the request headers for every 4xx/5xx proxied through the platform, so apps could see that a call failed but never why.Root cause
The host (
app-extension-componentevents.tsx (api)) catches the axios error and resolves theapiAdapterreply witherr.response.dispatchAdapterthen rejected{ ...response, config }, a flat object whose keys aredata / status / statusText / headers / config / requestwith noresponsewrapper.dispatchApiRequest'sif (err.response)branch therefore never ran, and the transport-error fallback built theResponsefromerr.stack/err.message/err.config.headers, none of which describe the HTTP reply.Separately,
axiosToFetchResponse(success path) readconfig.headers, i.e. the request headers, so apps could not read response headers fromapi()at all. That regressed in5a8bd80("refactor headers logic").Changes
dispatchAdapter— for HTTP errors (reply has adatakey) also nest the reply underresponse. The flat keys are kept, so anything readingerr.status/err.dataoff acreateAdapter()rejection keeps working. Host transport errors ({ status: 502|503|504, message, stack }) are rejected unchanged.dispatchApiRequest— converterr.responsewithaxiosToFetchResponse(object bodies become JSON, not[object Object]);err.config?.headerson the fallback.axiosToFetchResponse— build headers from the response headers; stripset-cookieandauthorization.No host change needed.
createAdapter()behaviour is additive only (one extraresponsekey on HTTP-error rejections).Tests
New
__test__/adapter.test.tsdrivesdispatchApiRequestanddispatchAdapterthrough a mocked post-robot:responseresponseJest 27 exposes no fetch globals in either environment, so
__test__/helpers/fetchEnvironment.jscopies Node's ownResponse/Headers/Blobinto the sandbox for this file.Full suite: 19 suites, 263 tests pass.
tsc --noEmitandwebpackbuild clean. ESLint: 0 errors in touched files (the 8 pre-existing warnings are insrc/types*, untouched). Prettier: new files formatted;adapter.tswas already non-conformant on develop at thedispatchAdaptersignature, left as-is to keep the diff focused.CI fixes (second commit)
Both
security-scaandsecurity-licensewere already red ondevelop; fixed here so the PR can merge.axios@1.12.2(lock) and its transitiveform-data@4.0.4/follow-redirects@1.15.9. Bumpedaxios^1.7.9→^1.20.0(the version Snyk recommends), which pullsform-data@4.0.6andfollow-redirects@1.16.1.npm audit --omit=devreports 0. Full suite,tscandwebpackstill pass; bundle 314 → 329 KiB.LICENSEcopyright range2022-2025→2022-2026; the policy scan greps for the current year.Follow-ups (not in this PR)
createAdapter()workaround (PR #1061).dispatchAdapterreject with a realAxiosErrorfor parity with axios.apiAdaptererror contract.🤖 Generated with Claude Code