{"record":{"id":"d9ad2ec2970af2b2","repo":"can1357/oh-my-pi","slug":"flickr-getsizes-request-failed","errorCode":null,"errorMessage":"flickr getSizes request failed","messagePattern":"flickr getSizes request failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/blob-broker/uploaders-image-hosts.ts","lineNumber":249,"sourceCode":"\t\t[\"hidden\", \"hidden\"],\n\t] as const;\n\tfor (const [option, parameter] of mappings) {\n\t\tconst value = optionString(config, option);\n\t\tif (value) fields[parameter] = value;\n\t}\n\treturn fields;\n}\n\nfunction flickrPhotoId(xml: string): string {\n\tconst status = /<rsp\\b[^>]*\\b(?:stat|status)=[\"']([^\"']+)[\"']/i.exec(xml)?.[1];\n\tif (status && status !== \"ok\") throw new Error(\"flickr rejected the upload\");\n\tconst photoId = /<photoid\\b[^>]*>([^<]+)<\\/photoid>/i.exec(xml)?.[1]?.trim();\n\tif (!photoId) throw new Error(\"flickr response did not include a photo ID\");\n\treturn photoId;\n}\n\nfunction largestFlickrSource(payload: Record<string, unknown>): string {\n\tif (payload.stat !== \"ok\") throw new Error(\"flickr getSizes request failed\");\n\tconst sizes = nestedRecord(payload, \"sizes\", \"flickr\").size;\n\tif (!Array.isArray(sizes)) throw new Error(\"flickr getSizes response did not include sizes\");\n\tfor (let index = sizes.length - 1; index >= 0; index--) {\n\t\tconst size = sizes[index];\n\t\tif (size && typeof size === \"object\" && !Array.isArray(size)) {\n\t\t\tconst source = (size as Record<string, unknown>).source;\n\t\t\tif (typeof source === \"string\" && source) return directUrl(source, \"flickr\");\n\t\t}\n\t}\n\tthrow new Error(\"flickr getSizes response did not include a direct image URL\");\n}\n\nfunction createFlickrUploader(config: DestinationRuntimeConfig): BlobUploader {\n\tconst credentials: FlickrOAuthCredentials = {\n\t\tconsumerKey: requireCredential(config, \"apiKey\"),\n\t\tconsumerSecret: requireCredential(config, \"apiSecret\"),\n\t\ttoken: requireCredential(config, \"oauthToken\"),\n\t\ttokenSecret: requireCredential(config, \"oauthTokenSecret\"),","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/blob-broker/uploaders-image-hosts.ts#L231-L267","documentation":"largestFlickrSource() throws this when the JSON payload from Flickr's flickr.photos.getSizes call has stat !== 'ok', meaning the API call itself failed (auth problem, invalid photo ID, Flickr error). The uploader cannot resolve a direct image URL without a successful getSizes response.","triggerScenarios":"Calling flickr.photos.getSizes with a photo ID that does not exist, is private, or whose OAuth signature/token is rejected — Flickr replies with stat: 'fail' and an error code/message.","commonSituations":"Expired or revoked Flickr OAuth token, photo deleted between upload and getSizes, wrong API key/secret pair, or Flickr rate limiting.","solutions":["Re-check the Flickr apiKey/apiSecret and OAuth token in the destination config","Inspect the getSizes response body for Flickr's error code and message (e.g. 1: Photo not found, 98: Invalid auth token)","Re-authenticate to obtain a fresh OAuth token","Retry after confirming the photo ID returned by the upload step is valid"],"exampleFix":"// before\nif (payload.stat !== \"ok\") throw new Error(\"flickr getSizes request failed\");\n// after — surface Flickr's own message\nif (payload.stat !== \"ok\") {\n\tconst msg = typeof payload.message === \"string\" ? payload.message : \"unknown flickr error\";\n\tthrow new Error(`flickr getSizes request failed (${payload.code ?? \"?\"}): ${msg}`);\n}","handlingStrategy":"retry","validationCode":"if (!oauthToken || isTokenExpired(oauthToken)) await refreshFlickrToken(config);","typeGuard":"function isFlickrOk(payload: Record<string, unknown>): boolean {\n\treturn payload.stat === \"ok\";\n}","tryCatchPattern":"try {\n\tconst src = await largestFlickrSource(payload);\n} catch (err) {\n\tif (err instanceof Error && err.message === \"flickr getSizes request failed\") {\n\t\tawait refreshFlickrToken();\n\t\treturn retryGetSizes();\n\t}\n\tthrow err;\n}","preventionTips":["Refresh Flickr OAuth tokens before expiry","Confirm the photo ID exists and is public before calling getSizes","Monitor Flickr API error codes (98 = invalid auth token) and alert on them","Add retry with backoff for transient Flickr failures"],"tags":["flickr","api","auth","response-parsing"],"backgroundTag":"api-request-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}