{"record":{"id":"03e40d017756c782","repo":"RocketChat/Rocket.Chat","slug":"result-error-03e40d","errorCode":null,"errorMessage":"${result.error}","messagePattern":"\\$\\{result\\.error\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/meteor/client/views/marketplace/hooks/useApps.ts","lineNumber":138,"sourceCode":"\t);\n\n\tuseEffect(() => {\n\t\treturn stream('apps', ([key]) => {\n\t\t\tif (['app/added', 'app/removed', 'app/updated', 'app/statusUpdate', 'app/settingUpdated'].includes(key)) {\n\t\t\t\tinvalidate();\n\t\t\t}\n\t\t\tif (['app/added', 'app/removed'].includes(key) && !isEnterprise) {\n\t\t\t\tinvalidateLicenseQuery();\n\t\t\t}\n\t\t});\n\t}, [invalidate, invalidateLicenseQuery, isEnterprise, stream]);\n\n\tconst marketplace = useQuery({\n\t\tqueryKey: marketplaceQueryKeys.appsMarketplace(canManageApps),\n\t\tqueryFn: async () => {\n\t\t\tconst result = await orchestrator.getAppsFromMarketplace(canManageApps);\n\t\t\tif (result.error && typeof result.error === 'string') {\n\t\t\t\tthrow new Error(result.error);\n\t\t\t}\n\t\t\treturn result.apps;\n\t\t},\n\t\tstaleTime: Infinity,\n\t\tplaceholderData: keepPreviousData,\n\t});\n\n\tconst instance = useQuery({\n\t\tqueryKey: marketplaceQueryKeys.appsInstance(canManageApps),\n\t\tqueryFn: async () => {\n\t\t\tconst result = await orchestrator.getInstalledApps().then((result: App[]) =>\n\t\t\t\tresult.map((current: App) => ({\n\t\t\t\t\t...current,\n\t\t\t\t\tinstalled: true,\n\t\t\t\t})),\n\t\t\t);\n\t\t\treturn result;\n\t\t},","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/client/views/marketplace/hooks/useApps.ts#L120-L156","documentation":"Thrown inside a React Query useQuery queryFn when orchestrator.getAppsFromMarketplace returns a result object whose error property is a string. The marketplace orchestrator returns a union type: either { apps: App[] } on success or { error: string } on failure. The queryFn checks for the error string and throws it so React Query treats the fetch as failed (triggering retry/error state).","triggerScenarios":"The marketplace API returns an error (e.g., marketplace not configured, network issue, server error, license limitation). The orchestrator fails to fetch apps and returns an error string. The App Engine service is unavailable. The user's license does not permit marketplace access.","commonSituations":"Marketplace URL not configured or unreachable on the server. App Engine microservice is down or misconfigured. Enterprise license expired or lacks marketplace entitlement. Network connectivity issue between client and server. Server-side rate limiting or timeout.","solutions":["Read the error string from the thrown Error.message to identify the specific marketplace failure.","Check server logs for the marketplace/App Engine error corresponding to the message.","Verify the marketplace settings (URL, token) are correctly configured in Rocket.Chat admin.","Handle the React Query error state in the UI to show a retry button or fallback."],"exampleFix":"// before: error swallowed or unhandled\nconst { data, error } = useMarketplace();\n// after: handle error state explicitly\nconst marketplace = useQuery({\n  queryFn: async () => {\n    const result = await orchestrator.getAppsFromMarketplace(canManageApps);\n    if (result.error && typeof result.error === 'string') {\n      throw new Error(result.error);\n    }\n    return result.apps;\n  },\n  retry: 1,\n});\n// in component:\nif (marketplace.isError) {\n  return <ErrorMessage error={marketplace.error} onRetry={() => marketplace.refetch()} />;\n}","handlingStrategy":"try-catch","validationCode":"const result = await orchestrator.getAppsFromMarketplace(canManageApps);\nif (result.error) {\n  // pre-check: log the error, show config guidance\n  console.warn('Marketplace error:', result.error);\n  return;\n}","typeGuard":"const isMarketplaceError = (result: any): result is { error: string } =>\n  result && typeof result.error === 'string';","tryCatchPattern":"// React Query handles this automatically:\nconst marketplace = useQuery({\n  queryFn: async () => {\n    const result = await orchestrator.getAppsFromMarketplace(canManageApps);\n    if (result.error && typeof result.error === 'string') {\n      throw new Error(result.error);\n    }\n    return result.apps;\n  },\n});\n// Access the error:\nif (marketplace.isError) {\n  console.error(marketplace.error?.message);\n}","preventionTips":["Check server marketplace/App Engine configuration when this error appears.","Use React Query's isError state to surface the error in the UI with a retry action.","Read the specific error string to diagnose whether it is network, license, or configuration related.","Monitor server logs for the root cause behind the orchestrator's error response."],"tags":["marketplace","app-engine","react-query","api-error","orchestrator"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}