{"record":{"id":"8949b2796408e215","repo":"cloudflare/cloudflared","slug":"failed-to-upload-checksum-0","errorCode":null,"errorMessage":"failed to upload checksum: {0}","messagePattern":"failed to upload checksum: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"github_release.py","lineNumber":53,"sourceCode":"\ndef send_hash(pkg_hash, name, version, account, namespace, api_token):\n    \"\"\" send the checksum of a file to workers kv \"\"\"\n    key = '{0}_{1}_{2}'.format(UPDATER_PREFIX, version, name)\n    headers = {\n        \"Content-Type\": \"application/json\",\n        \"Authorization\": \"Bearer \" + api_token,\n    }\n    response = requests.put(\n            BASE_KV_URL + account + \"/storage/kv/namespaces/\" + namespace + \"/values/\" + key,\n            headers=headers,\n            data=pkg_hash\n    )\n\n    if response.status_code != 200:\n        jsonResponse = response.json()\n        errors = jsonResponse[\"errors\"]\n        if len(errors) > 0:\n            raise Exception(\"failed to upload checksum: {0}\", errors[0])\n\n\n\ndef assert_tag_exists(repo, version):\n    \"\"\" Raise exception if repo does not contain a tag matching version \"\"\"\n    tags = repo.get_tags()\n    if not tags or tags[0].name != version:\n        raise Exception(\"Tag {} not found\".format(version))\n\n\ndef get_or_create_release(repo, version, dry_run=False, is_draft=False):\n    \"\"\"\n    Get a Github Release matching the version tag or create a new one.\n    If a conflict occurs on creation, attempt to fetch the Release on last time\n    \"\"\"\n    try:\n        release = repo.get_release(version)\n        logging.info(\"Release %s found\", version)","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/github_release.py#L35-L71","documentation":"send_hash raises this when the HTTP request used to store the asset checksum in Workers KV returns a status code other than 200 with at least one error entry in the JSON body. The exception carries the first API error object, though — like its siblings — the '{0}' placeholder is never interpolated, so the message stays literal and the details sit in args[1].","triggerScenarios":"Uploading a release asset whose checksum KV PUT/POST call fails: invalid KV api_token, wrong account_id or namespace_id, KV write permissions missing on the token, or the Cloudflare API being unavailable/rate-limited.","commonSituations":"CI publish jobs where the KV namespace was recreated (new namespace_id) or the token's scope was narrowed, causing authenticated-but-forbidden writes during github-release uploads.","solutions":["Inspect the exception's args[1] for the actual Cloudflare error code/message.","Verify the api_token has Workers KV Edit permission on the target namespace.","Confirm account_id and namespace_id match the existing namespace.","Fix the exception formatting to interpolate errors[0] into the message."],"exampleFix":"// before\nraise Exception(\"failed to upload checksum: {0}\", errors[0])\n// after\nraise Exception(\"failed to upload checksum: {}\".format(errors[0]))","handlingStrategy":"try-catch","validationCode":"if not kv_api_token or not kv_account_id or not namespace_id:\n    raise ValueError(\"KV credentials (token, account, namespace) must be set before upload\")","typeGuard":null,"tryCatchPattern":"try:\n    send_hash(kv, key, sha)\nexcept Exception as e:\n    logging.error(\"checksum upload failed: %s\", e.args[1] if len(e.args) > 1 else e)\n    raise SystemExit(1)","preventionTips":["Grant the token Workers KV Edit on the target namespace","Confirm the namespace_id after any namespace recreation","Retry once with backoff for transient 5xx before failing the release"],"tags":["cloudflare","kv","api","upload"],"backgroundTag":"http-error-response","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}