Make release creation an idempotent upsert instead of Get-then-Create - #34
Merged
Merged
Conversation
The 'does this release already exist' pre-check (client.Repository.Release.Get, deserializing Octokit's own Release model via the same unannotated reflection covered in #32/#33) is just as unreliable under Native AOT as the write side was. In the very next real release after #33, it silently failed, so CreateRelease ran unconditionally against a tag that already had a release and got: Octokit.ApiValidationException: {"code":"already_exists","field":"tag_name"} Rather than keep chasing which specific Octokit call breaks next, CreateOrUpdateRelease is now a self-contained upsert: always POST the release, and only on a 422 already_exists response resolve the existing release's id (via a minimal, source-generated-only GET - not Octokit's Release model) and PATCH it. No separate existence check, so nothing to be unreliable about. Verified the full create -> 422 already_exists -> GET id -> PATCH sequence end-to-end against a local HTTP listener from a real native-AOT linux-x64 build. Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #32/#33 (Octokit's request serialization dropping fields under Native AOT). This one's on the read side.
What happened
Both
assembly-rewriterandnupkg-validatorgot past release creation and label creation successfully this time (thanks to #32/#33), but then a concurrent CI run (amasterpush race, see context below) meant the release for that tag had already been created by the time the tag-triggered run got to this step. The pre-check that's supposed to catch that (client.Repository.Release.Get, deserializing Octokit's ownReleasemodel via the same unannotated reflection covered in #32/#33) silently failed too, soCreateReleaseran unconditionally and got:Why not just fix the Get call
Given #32 and #33 already showed two unrelated models breaking two different (and non-obvious) ways under Octokit's zero-annotation reflection serializer, I don't trust patching around individual failures here to be the last one. The more robust shape is to stop needing a separate, fallible existence check at all.
Fix
GitHubReleaseClient.CreateOrUpdateReleaseis now a self-contained upsert: always POST the release first. Only on a422 already_existsdoes it resolve the existing release's id — via a minimal, source-generated-only GET returning just{ id }, not Octokit'sReleasemodel — and PATCH it.ReleaseNotesRunner.CreateReleaseno longer callsReleaseExistsat all before writing.Verification
Simulated the full sequence (POST → 422 already_exists → GET id → PATCH) against a local
HttpListenerfrom a real native-AOTlinux-x64build:Made with Cursor