fix: handle non-JSON error message in submit 400 response - #57
Open
caroolcanelas2 wants to merge 1 commit into
Open
fix: handle non-JSON error message in submit 400 response#57caroolcanelas2 wants to merge 1 commit into
caroolcanelas2 wants to merge 1 commit into
Conversation
Previously, handleSubmitAppError assumed response.data.message from the
vtex.app-store-seller validation call was always a JSON-encoded string
and called JSON.parse on it unconditionally. When an upstream failure
(e.g. a 401 from an internal deploy-status check) is instead propagated
as a plain-text message ("Request failed with status code 401"),
JSON.parse throws a raw, unhandled SyntaxError that kills the CLI with
no actionable context for the user.
This wraps the parse in a try/catch and falls back to logging the raw
message, or a generic actionable hint (check publish + deploy) if the
message is empty.
Context: vtex.slack.com thread p1784654346302669 (TICKET #1434688) —
took ~3 weeks to root-cause a submit failure that was actually
"app published but not deployed", because the real error was masked
by this SyntaxError.
|
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.

0 New Issues
0 Fixed Issues
0 Accepted Issues
Problem
handleSubmitAppErrorassumesresponse.data.messagefrom thevtex.app-store-sellervalidation call is always a JSON-encoded string and callsJSON.parseon it unconditionally for HTTP 400 responses:When an upstream failure is instead propagated as a plain-text message (e.g.
"Request failed with status code 401", the default axios error string, likely leaking from an internal deploy-status check that failed),JSON.parsethrows a raw, unhandledSyntaxErrorthat kills the CLI process with zero actionable context:This masked the real, fixable cause (app published but not deployed) and cost ~3 weeks of investigation across Product Support and Engineering before it was root-caused. Slack thread: internal ticket
#1434688/APPS_4680.Fix
Wrap the
JSON.parsein atry/catch. On failure, fall back to logging the raw message (in case it's still useful plain text), or a generic, actionable hint if the message is empty:Follow-up (out of scope for this PR)
The root cause of why
app-store-sellerreturns an unparseable message in the first place (an internal 401 propagated as raw axios error text) should also be fixed server-side, so the message is precise rather than a generic hint. Flagging to the App Store Seller team separately.🤖 Generated with Claude Code