{"record":{"id":"42219c060b30109c","repo":"gitroomhq/postiz-app","slug":"unexpected-error","errorCode":null,"errorMessage":"Unexpected error","messagePattern":"Unexpected error","errorType":"http","errorClass":"HttpException","httpStatus":500,"severity":"error","filePath":"apps/backend/src/public-api/routes/v1/public.integrations.controller.ts","lineNumber":631,"sourceCode":"            throw new HttpException(\n              { msg: 'Channel disconnected due to expired token' },\n              401\n            );\n          }\n\n          const { accessToken } = data;\n\n          if (accessToken) {\n            getIntegration.token = accessToken;\n\n            if (integrationProvider.refreshWait) {\n              await timer(10000);\n            }\n\n            continue;\n          }\n        }\n        throw new HttpException({ msg: 'Unexpected error' }, 500);\n      }\n    }\n  }\n}\n","sourceCodeStart":613,"sourceCodeEnd":636,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/apps/backend/src/public-api/routes/v1/public.integrations.controller.ts#L613-L636","documentation":"triggerIntegrationTool wraps tool invocation in a while(true) loop with a 10-second timer between attempts; if every attempt falls through the retry branches without producing a success or early throw, the loop exits to a catch-all 500 'Unexpected error'. It signals an unclassifiable provider-side failure that persisted through all retries.","triggerScenarios":"POST to triggerIntegrationTool where the provider method keeps returning a falsy/unknown result shape (neither success nor a recognized retry condition) until the internal retry budget is exhausted; also any unexpected exception from the dynamic integrationProvider[body.methodName] call that is not caught by the token-refresh branch.","commonSituations":"Provider API returning an unexpected response schema (breaking change on the channel's API); provider method throwing a non-OAuth error repeatedly; network-level failures to the channel endpoint; invoking a tool with malformed arguments that the provider silently fails on.","solutions":["Inspect the backend logs at the time of the 500 to see the underlying provider exception and response payload","Test the same tool invocation from the UI to isolate whether it is specific to the public API call's arguments","Verify the arguments match the tool's expected schema (many tools fail silently on malformed input)","If the channel's API changed, update Postiz to a version with the fixed provider implementation"],"exampleFix":"// before\nconst res = await triggerTool(id, method, args); // throws 500 'Unexpected error'\n\n// after\n// capture and log the tool response/args to identify the provider-level failure\ntry {\n  const res = await triggerTool(id, method, args);\n} catch (e) {\n  if (e.status === 500) {\n    logger.error('tool failed', { id, method, args, body: e.response?.body });\n    // inspect backend logs for the underlying provider error\n  }\n  throw e;\n}","handlingStrategy":"retry","validationCode":"if (!body?.methodName || typeof body.methodName !== 'string') throw new Error('methodName required');\n// validate args against the tool's documented schema before calling","typeGuard":"const isUnexpectedToolError = (e: unknown): boolean =>\n  (e as any)?.status === 500 && (e as any)?.response?.msg === 'Unexpected error';","tryCatchPattern":"try {\n  await triggerTool(id, method, args);\n} catch (e: any) {\n  if (e?.status === 500) {\n    await sleep(5000);\n    return triggerTool(id, method, args); // single client-side retry; server already retried internally\n  }\n  throw e;\n}","preventionTips":["Log full tool args and correlation ids with each 500 for backend-log correlation","Snapshot provider API response shapes in tests to catch schema drift early","Keep backend updated so provider fixes for upstream API changes are picked up"],"tags":["public-api","provider-failure","retry-exhausted","http-500"],"backgroundTag":"upstream-provider-error","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}