From e3f5943a0c59b3e785f1da99036216bb962c5369 Mon Sep 17 00:00:00 2001 From: Carolina Canelas Date: Wed, 12 Aug 2026 15:54:59 -0300 Subject: [PATCH] fix: handle non-JSON error message in submit 400 response MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/lib/constants/Messages.ts | 4 ++++ src/modules/submit.ts | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/lib/constants/Messages.ts b/src/lib/constants/Messages.ts index 42c2fe5..01cd729 100644 --- a/src/lib/constants/Messages.ts +++ b/src/lib/constants/Messages.ts @@ -11,6 +11,10 @@ export const Messages = { APP_NOT_INSTALLED: "The app you're trying to submit must be installed on this workspace.", + + VALIDATION_FAILED_UNKNOWN_REASON: + 'Your submission could not be validated. Make sure your app is both published and deployed before running `vtex submit`, then try again. If the problem persists, contact VTEX support.', + ENTER_GITHUB_USERNAME: 'Enter your Github username', ENTER_STATUS_CHECK_URL: 'Enter a URL from where we can test your app working. It can be in your workspace', diff --git a/src/modules/submit.ts b/src/modules/submit.ts index 99ed28e..7ae45b4 100644 --- a/src/modules/submit.ts +++ b/src/modules/submit.ts @@ -14,7 +14,20 @@ const handleSubmitAppError = (e: any) => { switch (status) { case 400: { - logger.error(Messages.OBJECT_FORMAT, JSON.parse(response?.data?.message)) + try { + logger.error( + Messages.OBJECT_FORMAT, + JSON.parse(response?.data?.message) + ) + } catch { + // response.data.message isn't valid JSON (e.g. an upstream service propagated + // a raw error string instead of a structured validation payload). Surface a + // clear, actionable message instead of letting the SyntaxError bubble up raw. + logger.error( + response?.data?.message ?? Messages.VALIDATION_FAILED_UNKNOWN_REASON + ) + } + break }