{"record":{"id":"f0b3c5e5ca970a9b","repo":"can1357/oh-my-pi","slug":"backblaze-b2-bucket-not-found-bucketname","errorCode":null,"errorMessage":"Backblaze B2 bucket not found: ${bucketName}","messagePattern":"Backblaze B2 bucket not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/blob-broker/uploaders-object-storage.ts","lineNumber":514,"sourceCode":"\tbucketName: string,\n): Promise<B2Bucket> {\n\tconst value = await b2Json(\n\t\tconfig,\n\t\t`${authorization.apiUrl}/b2api/v2/b2_list_buckets`,\n\t\tauthorization.authorizationToken,\n\t\t{ accountId: authorization.accountId, bucketName },\n\t);\n\tconst buckets = asRecord(value, \"Backblaze B2 bucket listing\").buckets;\n\tif (!Array.isArray(buckets)) throw new Error(\"Backblaze B2 bucket listing omitted buckets\");\n\tfor (const candidate of buckets) {\n\t\tif (optionalStringField(candidate, \"bucketName\") !== bucketName) continue;\n\t\treturn {\n\t\t\tbucketId: requiredStringField(candidate, \"bucketId\", \"Backblaze B2 bucket\"),\n\t\t\tbucketName,\n\t\t\tbucketType: requiredStringField(candidate, \"bucketType\", \"Backblaze B2 bucket\"),\n\t\t};\n\t}\n\tthrow new Error(`Backblaze B2 bucket not found: ${bucketName}`);\n}\n\nasync function b2UploadTarget(\n\tconfig: DestinationRuntimeConfig,\n\tauthorization: B2Authorization,\n\tbucketId: string,\n): Promise<B2UploadTarget> {\n\tconst value = await b2Json(\n\t\tconfig,\n\t\t`${authorization.apiUrl}/b2api/v2/b2_get_upload_url`,\n\t\tauthorization.authorizationToken,\n\t\t{ bucketId },\n\t);\n\treturn {\n\t\tuploadUrl: requiredStringField(value, \"uploadUrl\", \"Backblaze B2 upload URL\"),\n\t\tauthorizationToken: requiredStringField(value, \"authorizationToken\", \"Backblaze B2 upload URL\"),\n\t};\n}","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/blob-broker/uploaders-object-storage.ts#L496-L532","documentation":"After iterating the b2_list_buckets response, if no bucket's bucketName matches the configured bucketName, the code throws `Backblaze B2 bucket not found: <name>`. The listing succeeded; the configured bucket simply does not exist (or is not visible to the key) on that B2 account.","triggerScenarios":"b2_list_buckets returned a buckets array but none matched the configured bucketName — the bucket was deleted/renamed, belongs to a different B2 account, or the application key is restricted to other buckets (or a bucketId-only key that cannot see it).","commonSituations":"Typo in the bucket name in the destination config; bucket deleted after config was written; using a restricted master-less application key scoped to a different bucket; environment mismatch (staging config pointing at production account or vice versa).","solutions":["Verify the bucket exists in the B2 web console under the account the key belongs to.","Check for typos/case differences in the configured bucketName (names are case-sensitive).","Regenerate or broaden the application key so it can list/see the target bucket, or use a key restricted to exactly that bucket.","Point the destination config at the correct account/key for the environment you intend."],"exampleFix":"// before\n{ \"provider\": \"b2\", \"bucketName\": \"my-images\" } // actual bucket is \"my_images\"\n// after\n{ \"provider\": \"b2\", \"bucketName\": \"my_images\" }","handlingStrategy":"validation","validationCode":"import { S3Client, HeadBucketCommand } from \"@aws-sdk/client-s3\"; // or B2 native API\n// before upload: verify bucket visibility with the same key\nconst listing = await b2ListBuckets(config);\nif (!listing.buckets.some((b) => b.bucketName === configuredName)) {\n  throw new Error(`bucket '${configuredName}' not visible to this application key; create it or fix config`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await publish(destination, request);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Backblaze B2 bucket not found\")) {\n    console.error(`${err.message} — verify bucket name and application key scope in the B2 console`);\n  } else throw err;\n}","preventionTips":["verify bucket existence in the B2 console right after writing the destination config","use a per-bucket application key so visibility matches intent","check bucket name spelling/case (names are exact)","re-validate configs after account migrations or bucket renames"],"tags":["object-storage","b2","configuration","bucket-not-found"],"backgroundTag":"bucket-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}