{"record":{"id":"e42c4e0f655607ea","repo":"RocketChat/Rocket.Chat","slug":"invalid-response-from-the-marketplace","errorCode":null,"errorMessage":"Invalid response from the Marketplace","messagePattern":"Invalid response from the Marketplace","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/apps/communication/rest.ts","lineNumber":337,"sourceCode":"\t\t\t\t\t\t\t\t\t\tignoreSsrfValidation: true,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t.catch((cause) => {\n\t\t\t\t\t\t\t\t\t\tthrow new Error('App metadata download failed', { cause });\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t]);\n\n\t\t\t\t\t\t\tif (downloadResponse.headers.get('content-type') !== 'application/zip') {\n\t\t\t\t\t\t\t\tthrow new Error('Invalid url. It doesn\\'t exist or is not \"application/zip\".');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbuff = Buffer.from(await downloadResponse.arrayBuffer());\n\t\t\t\t\t\t\tmarketplaceInfo = await marketplaceResponse.json();\n\n\t\t\t\t\t\t\t// Note: marketplace responds with an array of the marketplace info on the app, but it is expected\n\t\t\t\t\t\t\t// to always have one element since we are fetching a specific app version.\n\t\t\t\t\t\t\tif (!Array.isArray(marketplaceInfo) || marketplaceInfo?.length !== 1) {\n\t\t\t\t\t\t\t\torchestrator.getRocketChatLogger().error({ msg: 'Error getting app information from marketplace', marketplaceInfo });\n\t\t\t\t\t\t\t\tthrow new Error('Invalid response from the Marketplace');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tpermissionsGranted = this.bodyParams.permissionsGranted;\n\t\t\t\t\t\t} catch (err: unknown) {\n\t\t\t\t\t\t\tlet message;\n\n\t\t\t\t\t\t\tif (err instanceof Error) {\n\t\t\t\t\t\t\t\torchestrator.getRocketChatLogger().error({ msg: 'Error installing app from marketplace:', err });\n\t\t\t\t\t\t\t\tmessage = err.message;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tmessage = err;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn API.v1.failure({ error: message });\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst app = await getUploadFormData(\n\t\t\t\t\t\t\t{","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/apps/communication/rest.ts#L319-L355","documentation":"Thrown after the marketplace metadata fetch succeeds but the parsed JSON is not a single-element array. The marketplace is expected to return exactly one element (info for the requested app version); any other shape (empty array, multi-element array, or a non-array object) is treated as an invalid marketplace response. The response is logged via orchestrator.getRocketChatLogger().error before throwing.","triggerScenarios":"POST /api/v1/apps marketplace install where the v1/apps/{appId}?appVersion={version} endpoint returns an unexpected payload: an empty array (app/version gone), an object with an error field rather than the array, or multiple matches.","commonSituations":"The requested app version was deleted/unpublished between the listing call and the install call; marketplace API version drift where the contract changed; appId casing or slug mismatch causing the metadata endpoint to return a different shape.","solutions":["Verify the appId and version still exist on the marketplace (browse the marketplace page).","Re-fetch the app listing to get a current, valid version number and retry the install.","Check server logs for the marketplaceInfo payload that triggered the throw (it is logged at error level).","If the marketplace API contract changed, update Rocket.Chat to a version compatible with the current marketplace."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"function isSingleMarketplaceInfo(payload: unknown): payload is IMarketplaceInfo[] {\n  return Array.isArray(payload) && payload.length === 1;\n}\n\nconst info = await marketplaceResponse.json();\nif (!isSingleMarketplaceInfo(info)) {\n  throw new Error('Marketplace returned unexpected metadata shape');\n}","typeGuard":"const isSingleElementArray = <T>(value: unknown): value is [T] =>\n  Array.isArray(value) && value.length === 1;","tryCatchPattern":"try {\n  await installMarketplaceApp(appId, version);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Invalid response from the Marketplace') {\n    // refresh app listing; the version may have been unpublished\n    await refreshAppListing();\n    retryWithCurrentVersion();\n  }\n}","preventionTips":["Re-fetch the marketplace listing immediately before install to confirm the version still exists.","Treat an empty/multi metadata array as a stale-cache signal and refresh.","Log the full marketplaceInfo payload when this fires to diagnose contract drift."],"tags":["apps-engine","marketplace","schema","install"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}