fix(agent-designer): model write-check rejects models the picker lists (403)#599
Merged
Merged
Conversation
The catalog lists models via ModelAccessService.filter_accessible_models, but design-time write validation used can_access_model — and the two disagree. filter_accessible_models grants access whenever the model id is in the user's AppRole permissions.models; can_access_model only honors that membership when the model record ALSO carries a non-empty allowed_app_roles. So a model granted purely via the user's AppRole (empty allowed_app_roles) was listed by the picker but rejected on save with a 403 — and the runtime resolver (membership-based) would actually have allowed it. Validate the model with the same filter_accessible_models predicate the catalog uses, so 'if the palette offers it, the write accepts it' holds by construction. Adds a regression test for the empty-allowed_app_roles grant. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Follow-up to #598 (merged). The model-access fix landed on the branch after #598's merge commit, so it isn't in
developyet — this PR carries just that one commit.The bug
The Agent Designer model picker and the save path use two different access checks that disagree:
ModelAccessService.filter_accessible_models, which grants a model whenever its id is in the user's AppRolepermissions.models.ModelAccessService.can_access_model, which only honors that same AppRole membership when the model record also has a non-emptyallowed_app_roles(the membership check is nested underif model.allowed_app_roles:).So a model granted purely via the user's AppRole, whose record has an empty
allowed_app_roles, is listed by the picker but 403s on save — e.g.us.anthropic.claude-sonnet-4-6. The runtime resolver checks membership directly, so it would actually have allowed the model; the write check was the sole outlier.The fix
Design-time validation now uses the same
filter_accessible_modelspredicate the catalog uses, so "if the palette offers it, the write accepts it" holds by construction. Adds a regression test for the empty-allowed_app_rolesmembership grant.Testing
/agentsroute tests pass (incl. the new regression test).Reviewer note
Base is
develop. The diff is a single commit (128729a9) — the other Phase 4 commits are already indevelopvia #598.🤖 Generated with Claude Code