Repository navigation
Conversation
TemplateConverter used the unqualified "id :: text" resource ID matcher, but GetTemplatesWithFilter joins template_versions, which also has an id column. A token allow-list naming a specific template therefore made GetAuthorizedTemplates fail with `column reference "id" is ambiguous`. Qualify the ID as "t.id", matching the existing t.organization_id. Fixes #32059
This branch was previously deployed
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.
A token whose allow-list names a specific template (
template:<uuid>) got a 500 from anything that loads templates throughGetAuthorizedTemplates, for exampleGET /api/v2/workspaces/<id>, failing withpq: column reference "id" is ambiguous.TemplateConverterused the sharedresourceIDMatcher(), which emits an unqualifiedid :: text.GetTemplatesWithFilterjoinstemplate_versions, which also has anidcolumn. The ID predicate only appears when the allow-list names a concrete ID, so wildcard allow-lists were unaffected. The converter now emitst.id :: text, matching the existingt.organization_idmatcher.Adds a DB regression test that runs
GetAuthorizedTemplateswith a single-template allow-list against Postgres (fails onmainwith the ambiguous-column error), plus aregosqlcompile case.Fixes #32059
Implementation notes
TemplateConverteris changed. Other converters that still use the unqualifiedresourceIDMatcher()and back queries with joins could hit the same error with a specific-ID allow-list.AuditLogConverter(audit log queries joinusers,organizations,workspaces,workspace_builds) andConnectionLogConverter(joinusers,organizations) look likely.AIBridgeInterceptionConvertermay be affected too. These are unverified and left for a follow-up.go test ./coderd/rbac/regosql/..., targeted./coderd/databasetests (TestGetAuthorizedTemplatesAllowList,TestGetTemplatesWithAgentsAllowedFilter),./coderd/database/dbauthz,./coderd/rbac,go vet,golangci-lint.