{"record":{"id":"62a6eac835606568","repo":"gitroomhq/postiz-app","slug":"failed-to-get-profile","errorCode":null,"errorMessage":"Failed to get profile","messagePattern":"Failed to get profile","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"libraries/nestjs-libraries/src/integrations/social/moltbook.provider.ts","lineNumber":82,"sourceCode":"      `${MOLTBOOK_API_BASE}/agents/status`,\n      {\n        headers: { Authorization: `Bearer ${apiKey}` },\n      }\n    );\n\n    return response.data;\n  }\n\n  async getAgentProfile(apiKey: string) {\n    const response = await this.getSsrfSafeAxios().get(\n      `${MOLTBOOK_API_BASE}/agents/me`,\n      {\n        headers: { Authorization: `Bearer ${apiKey}` },\n      }\n    );\n\n    if (!response.data.success) {\n      throw new Error(response.data.error || 'Failed to get profile');\n    }\n\n    return response.data.agent;\n  }\n\n  async authenticate(params: {\n    code: string;\n    codeVerifier: string;\n    refresh?: string;\n  }) {\n    const apiKey = params.code;\n\n    const profile = await this.getAgentProfile(apiKey);\n\n    return {\n      id: profile.name || profile.id,\n      name: profile.display_name || profile.name,\n      accessToken: apiKey,","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/integrations/social/moltbook.provider.ts#L64-L100","documentation":"MoltbookProvider.getAgentProfile GETs the agent profile with the bearer apiKey and got success=false in the body. Throws the server's error text or the fallback 'Failed to get profile'. Typically an auth/API-key problem on Moltbook's side.","triggerScenarios":"GET profile with an invalid, revoked, or mismatched api key; wrong MOLTBOOK_API_BASE; or agent deleted server-side.","commonSituations":"Stale/rotated API key stored in the integration, agent unregistered, environment mismatch (key from staging used against prod).","solutions":["Verify the apiKey matches the registered agent on the same MOLTBOOK_API_BASE","Re-register the agent to obtain a fresh key if revoked","Check MOLTBOOK_API_BASE env configuration","Inspect response.data.error for the exact server reason"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const ok = await getAgentProfile(apiKey).then(() => true).catch(() => false);\nif (!ok) await reRegisterAgent();","typeGuard":null,"tryCatchPattern":"catch (e) { if (/Failed to get profile/.test((e as Error).message)) { await rotateApiKey(); } }","preventionTips":["Health-check agent keys on a schedule","Store keys per environment, never cross environments"],"tags":["moltbook","api-key","profile"],"backgroundTag":"api-key-invalid","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}