{"record":{"id":"93b8877975ca500d","repo":"diegosouzapw/OmniRoute","slug":"decodecredentialblob-invalid-format-must-start","errorCode":null,"errorMessage":"decodeCredentialBlob: invalid format — must start with \"${CREDENTIAL_BLOB_PREFIX}\"","messagePattern":"decodeCredentialBlob: invalid format — must start with \"(.+?)\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/oauth/credentialBlob.ts","lineNumber":71,"sourceCode":"  }\n  const payload = {\n    v: CREDENTIAL_BLOB_VERSION,\n    provider: input.provider.trim(),\n    tokens: input.tokens,\n  };\n  const json = JSON.stringify(payload);\n  const b64 = Buffer.from(json, \"utf8\").toString(\"base64url\");\n  return `${CREDENTIAL_BLOB_PREFIX}${b64}`;\n}\n\n/**\n * Decode a credential blob produced by {@link encodeCredentialBlob}.\n * Validates the prefix, version, JSON shape, and the presence of an access_token.\n * 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(","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/oauth/credentialBlob.ts#L53-L89","documentation":"Error \"decodeCredentialBlob: invalid format — must start with \"${CREDENTIAL_BLOB_PREFIX}\"\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/oauth/credentialBlob.ts:71 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}