{"record":{"id":"9e48bf3b29b7db54","repo":"diegosouzapw/OmniRoute","slug":"decodecredentialblob-invalid-payload-could-not","errorCode":null,"errorMessage":"decodeCredentialBlob: invalid payload — could not parse JSON","messagePattern":"decodeCredentialBlob: invalid payload — could not parse JSON","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/oauth/credentialBlob.ts","lineNumber":85,"sourceCode":" * Throws a descriptive error on any malformed/tampered/unsupported input.\n */\nexport function decodeCredentialBlob(blob: string): CredentialBlob {\n  if (typeof blob !== \"string\" || !blob.startsWith(CREDENTIAL_BLOB_PREFIX)) {\n    throw new Error(\n      `decodeCredentialBlob: invalid format — must start with \"${CREDENTIAL_BLOB_PREFIX}\"`\n    );\n  }\n  const b64 = blob.slice(CREDENTIAL_BLOB_PREFIX.length).trim();\n  if (!/^[A-Za-z0-9_-]+$/.test(b64)) {\n    throw new Error(\"decodeCredentialBlob: invalid payload — not base64url\");\n  }\n\n  let parsed: { v?: unknown; provider?: unknown; tokens?: unknown };\n  try {\n    const json = Buffer.from(b64, \"base64url\").toString(\"utf8\");\n    parsed = JSON.parse(json);\n  } catch {\n    throw new Error(\"decodeCredentialBlob: invalid payload — could not parse JSON\");\n  }\n\n  if (parsed.v !== CREDENTIAL_BLOB_VERSION) {\n    throw new Error(\n      `decodeCredentialBlob: unsupported blob version ${String(parsed.v)} (expected ${CREDENTIAL_BLOB_VERSION})`\n    );\n  }\n  if (typeof parsed.provider !== \"string\" || !parsed.provider.trim()) {\n    throw new Error(\"decodeCredentialBlob: invalid payload — missing provider\");\n  }\n  const tokens = parsed.tokens as CredentialBlobTokens | undefined;\n  if (!tokens || typeof tokens !== \"object\") {\n    throw new Error(\"decodeCredentialBlob: invalid payload — missing tokens\");\n  }\n  if (typeof tokens.access_token !== \"string\" || !tokens.access_token) {\n    throw new Error(\"decodeCredentialBlob: invalid payload — missing access_token\");\n  }\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/oauth/credentialBlob.ts#L67-L103","documentation":"Buffer.from(b64, 'base64url').toString('utf8') produced bytes that JSON.parse rejected, so the decoded payload is not valid JSON. The blob passed the charset and prefix checks but its content is corrupted or tampered with.","triggerScenarios":"Thrown at src/lib/oauth/credentialBlob.ts:85 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-export the blob from the source instance","Verify the paste did not drop characters"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}