{"record":{"id":"fbe94c2a451fcf73","repo":"cloudflare/cloudflared","slug":"tag-not-found","errorCode":null,"errorMessage":"Tag {} not found","messagePattern":"Tag (.+?) not found","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"github_release.py","lineNumber":61,"sourceCode":"    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)\n        return release\n    except UnknownObjectException:\n        logging.info(\"Release %s not found\", version)\n\n    # We don't want to create a new release tag if one doesn't already exist\n    assert_tag_exists(repo, version)\n\n    if dry_run:","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/github_release.py#L43-L79","documentation":"assert_tag_exists verifies that the newest tag on the GitHub repository matches the release version being published; if the repo has no tags at all, or tags[0].name != version, it raises this exception. It assumes get_tags() returns tags sorted with the most recent first, so a version that exists but is not the latest tag will also fail.","triggerScenarios":"Calling get_or_create_release (which calls assert_tag_exists) with a version that was never tagged, a version string that does not exactly match the tag name (e.g. missing 'v' prefix: '1.2.3' vs tag 'v1.2.3'), or when the tag exists but is older than another tag.","commonSituations":"Forgetting to run 'git push --tags' before the release job; typos in --release-version; projects where CI tags the repo after the release step instead of before; repos where get_tags() pagination hides the requested tag.","solutions":["Ensure the tag is created and pushed to the remote before running the release script (git tag vX.Y.Z && git push origin vX.Y.Z).","Verify the version argument matches the tag name exactly, including the 'v' prefix.","Instead of relying on tags[0], iterate all tags to check membership: if not any(t.name == version for t in tags).","Re-run the release pipeline after the tag is present."],"exampleFix":"// before\nif not tags or tags[0].name != version:\n    raise Exception(\"Tag {} not found\".format(version))\n// after\nif not any(tag.name == version for tag in tags):\n    raise Exception(\"Tag {} not found\".format(version))","handlingStrategy":"validation","validationCode":"tags = repo.get_tags()\nif not any(t.name == version for t in tags):\n    raise SystemExit(f\"tag {version} missing on remote; push it before releasing\")","typeGuard":null,"tryCatchPattern":"try:\n    release = get_or_create_release(repo, version)\nexcept Exception as e:\n    logging.error(\"release aborted: %s\", e)\n    sys.exit(1)","preventionTips":["Push tags (git push --tags) before running the release job","Make the version argument exactly match the tag name, including 'v' prefix","Have CI verify the tag exists as a first pipeline step"],"tags":["git","github","tagging","release"],"backgroundTag":"resource-not-found","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}