Skip to content

[FIX] ai_tool: non-admin tool access and valid date output schema - #125

Open
dreispt wants to merge 2 commits into
OCA:19.0from
dreispt:19.0-fix-ai_tool
Open

dreispt wants to merge 2 commits into
OCA:19.0from
dreispt:19.0-fix-ai_tool

Conversation

@dreispt

@dreispt dreispt commented Oct 7, 2026

Copy link
Copy Markdown
Member

Supersedes #119.

Two fixes needed for ai_tool to be usable by non-admin users and MCP clients on 19.0:

  • [FIX] ai_tool: resolve tool model metadata with sudo — cherry-picked from [19.0][FIX] ai_tool: date output schema and tool model metadata access #119 preserving @nobuQuartile's authorship. Since 19.0, ir.model is no longer readable by internal users (base.group_user gets perm_read=0), so _get_tool_definition and _execute_tool raised AccessError for non-admin callers — e.g. ai_oca_mcp keys bound to internal users. The ir.model name lookup is resolved via sudo(); the tool still executes with the caller's own permissions.
  • [FIX] ai_tool: _ai_get_date declares an invalid JSON Schema type — equivalent to [19.0][FIX] ai_tool: date output schema and tool model metadata access #119's second commit, re-implemented because that commit is authored by a bot account (zachdreambot), which cannot pass the OCA CLA check. date is not a JSON Schema type; the RFC 3339 {"type": "string", "format": "date"} declaration is what MCP clients expect.

nobuQuartile and others added 2 commits October 7, 2026 18:03
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.

(cherry picked from commit 16beaa7)
'date' is not a JSON Schema type, so the declared output schema is not
valid for MCP clients validating against it. Declare the RFC 3339
format instead.

Assisted-by: Devin:SWE-2 High
dreispt added a commit to dreispt/ai that referenced this pull request Oct 7, 2026
Port ai_tool_read from OCA#122 to 19.0.

- Manifest version bump.
- user_has_groups() removed: use res.users.has_groups().
- check_access_rights() deprecated since 18.0: use has_access() /
  check_access().
- View xpath targets use <list> instead of <tree>.
- display_name is never stored in 19.0, so it is excluded everywhere;
  adjust test_display_name_hidden.
- Replace setup/ symlink dir with the whool pyproject.toml convention.

Requires the ai_tool fixes from OCA#125, cherry-picked in the
preceding commits (ir.model is not readable by internal users in 19.0).

Assisted-by: Devin:SWE-2 High
dreispt added a commit to dreispt/ai that referenced this pull request Oct 7, 2026
Port ai_tool_read from OCA#122 to 19.0.

- Manifest version bump.
- user_has_groups() removed: use res.users.has_groups().
- check_access_rights() deprecated since 18.0: use has_access() /
  check_access().
- View xpath targets use <list> instead of <tree>.
- display_name is never stored in 19.0, so it is excluded everywhere;
  adjust test_display_name_hidden.
- Replace setup/ symlink dir with the whool pyproject.toml convention.

Requires the ai_tool fixes from OCA#125, cherry-picked in the
preceding commits (ir.model is not readable by internal users in 19.0).

Assisted-by: Devin:SWE-2 High

@nobuQuartile nobuQuartile left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for recreating PR!
LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants