{"record":{"id":"88ce5ed8be5cdfa0","repo":"cloudflare/cloudflared","slug":"failed-to-get-checksums-0","errorCode":null,"errorMessage":"failed to get checksums: {0}","messagePattern":"failed to get checksums: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"github_message.py","lineNumber":35,"sourceCode":"GITHUB_CONFLICT_CODE = \"already_exists\"\nBASE_KV_URL = 'https://api.cloudflare.com/client/v4/accounts/'\n\n\ndef kv_get_keys(prefix, account, namespace, api_token):\n    \"\"\" get the KV keys for a given prefix \"\"\"\n    response = requests.get(\n        BASE_KV_URL + account + \"/storage/kv/namespaces/\" +\n        namespace + \"/keys\" + \"?prefix=\" + prefix,\n        headers={\n            \"Content-Type\": \"application/json\",\n            \"Authorization\": \"Bearer \" + api_token,\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 get checksums: {0}\", errors[0])\n    return response.json()[\"result\"]\n\n\ndef kv_get_value(key, account, namespace, api_token):\n    \"\"\" get the KV value for a provided key \"\"\"\n    response = requests.get(\n        BASE_KV_URL + account + \"/storage/kv/namespaces/\" + namespace + \"/values/\" + key,\n        headers={\n            \"Content-Type\": \"application/json\",\n            \"Authorization\": \"Bearer \" + api_token,\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 get checksums: {0}\", errors[0])\n    return response.text","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/github_message.py#L17-L53","documentation":"kv_get_keys raises this when the Cloudflare Workers KV list-keys API returns a non-200 status code with at least one error entry in the JSON body. The exception carries the first API error object from the response. Note the message is formatted incorrectly: Exception('failed to get checksums: {0}', errors[0]) passes the placeholder literally and errors[0] becomes the exception's second argument, so the logged message never contains the actual error details.","triggerScenarios":"Calling kv_get_keys when the Cloudflare API responds with HTTP != 200 and a non-empty errors array — e.g. invalid/expired api_token, wrong account id or namespace_id, wrong base URL, or KV API downtime.","commonSituations":"CI release jobs where the KV_API_TOKEN secret is missing or rotated, a namespace_id pointing to a deleted namespace, or an account_id mismatch (token scoped to another account).","solutions":["Inspect the raised exception's args[1] (the first API error object) to identify the actual Cloudflare error code and message.","Verify the API token is valid and has Workers KV read permissions for the namespace.","Confirm account id and namespace_id are correct and the namespace still exists.","Fix the exception formatting to use str.format or an f-string so the real error text is in the message."],"exampleFix":"// before\nraise Exception(\"failed to get checksums: {0}\", errors[0])\n// after\nraise Exception(\"failed to get checksums: {0}\".format(errors[0]))","handlingStrategy":"validation","validationCode":"def kv_get_keys(account, namespace, api_token):\n    if not api_token or not account or not namespace:\n        raise ValueError(\"account, namespace and api_token are required\")\n    resp = requests.get(url, headers={\"Authorization\": f\"Bearer {api_token}\"}, timeout=30)\n    if resp.status_code == 401 or resp.status_code == 403:\n        raise PermissionError(\"KV token invalid or lacks permissions\")\n    resp.raise_for_status()","typeGuard":null,"tryCatchPattern":"try:\n    keys = kv_get_keys(account, namespace, token)\nexcept Exception as e:\n    api_err = e.args[1] if len(e.args) > 1 else e\n    logging.error(\"KV list failed: %s\", api_err)\n    sys.exit(1)","preventionTips":["Pre-flight a cheap KV API call with the token before the release job starts","Keep KV token, account id, and namespace id in validated CI variables","Fix and use the errors[0] detail in exception messages for faster triage"],"tags":["cloudflare","kv","api","python"],"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"}