mirror of
https://github.com/coder/coder.git
synced 2026-06-03 04:58:23 +00:00
7fc8a0829a
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 `:one` lookup (which silently picked the newest agent) to a `:many` lookup 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, and `continue` past candidates whose build is not current. 1 file changed, no SQL/migration/schema changes. > Generated by Coder Agents on behalf of @f0ssel