fix(coderd): skip stale agents from prior builds in instance-identity auth#25443
Merged
Conversation
8f54fbe to
0900a1e
Compare
0900a1e to
496f372
Compare
… auth Inside the existing per-candidate loop in handleAuthInstanceID, add a latest-build check: parse the provisioner job input to get the workspace build, then compare against the latest build for that workspace. Skip candidates whose build is not current. This prevents stale agents from prior builds (which share the same instance ID) from triggering false HTTP 409 ambiguity errors.
496f372 to
a7a7914
Compare
ibetitsmike
approved these changes
May 18, 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.
Fixes the HTTP 409 ambiguity errors that occur during instance-identity auth when stale workspace agents from prior builds accumulate with the same
auth_instance_id.Problem
#24325 changed the instance-identity auth path from a
:onelookup (which silently picked the newest agent) to a:manylookup with ambiguity rejection. This caused HTTP 409 errors for workspaces whose EC2/Azure/GCP instances had been through multiple builds, because old agents from prior builds (sharing the same instance ID) were still returned by the query.Solution
Inside the existing per-candidate loop in
handleAuthInstanceID(which already does per-candidate DB calls for resource and job lookups), add a latest-build check: parse the provisioner job input to get the workspace build, compare against the latest build for that workspace, andcontinuepast candidates whose build is not current.1 file changed, no SQL/migration/schema changes.