[16.0][FIX] ai_tool: resolve tool model metadata with sudo - #94
Open
nobuQuartile wants to merge 1 commit into
Open
[16.0][FIX] ai_tool: resolve tool model metadata with sudo#94nobuQuartile wants to merge 1 commit into
nobuQuartile wants to merge 1 commit into
Conversation
nobuQuartile
marked this pull request as draft
July 21, 2026 00:35
nobuQuartile
force-pushed
the
16.0-fix-ai_tool-1
branch
2 times, most recently
from
July 21, 2026 00:50
054c400 to
501267b
Compare
Building and dispatching a tool reads ir.model via model_id, which a plain internal user (base.group_user) cannot access. Resolve the model name with sudo() while keeping the actual tool execution under the caller's own permissions, so non-admin MCP keys can list and call tools. Add a regression test exercising a non-admin user through _get_tool_definition and _execute_tool.
nobuQuartile
force-pushed
the
16.0-fix-ai_tool-1
branch
from
July 21, 2026 00:53
501267b to
16beaa7
Compare
nobuQuartile
marked this pull request as ready for review
July 21, 2026 00:54
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.
Problem
When a tool is listed or executed on behalf of a non-admin user (a plain
base.group_userinternal user), the operation fails with:AiTool._get_tool_definitionandAiTool._execute_tooldereferenceself.model_id.model, which reads their.modelrecord. Readingir.modelrequires the Administration / Access Rights group, so any flow that runs as
a regular internal user (e.g.
ai_oca_mcpkeys owned by a non-admin user, wherethe controller runs
with_user(key.user_id)) is rejected before it can list orcall any tool.
Fix
Resolving which model/function a tool maps to is metadata, not user data.
Read the model name via
sudo(), while keeping the actual tool execution underthe caller's own permissions (
self.env[model]/record). Access control onthe real data operation is therefore unchanged; only the metadata lookup and
dispatch are allowed to proceed for non-admin users.
@qrtl