Loading
fix: #3583044 Say tool:run ran as anonymous when access is denied
Closes #3583044 (closed)
What changed
When tool:run is denied access and --uid was omitted, the message says it ran as anonymous and names the option:
Access denied for tool 'permission_gated_tool': The 'administer users' permission is required. Ran as anonymous (uid 0); pass --uid=<id> to run as a user.- Only when
--uidis omitted. An explicit--uid=0is deliberate and keeps the plain message. - It states what happened and does not suggest uid 1, so it doesn't push agents toward the superuser.
error_typestaysaccess_denied.
Testing
ToolRunCommandTest::testRunToolAccessDeniedAnonymousHint() covers omitted --uid (hint, JSON), --uid=0 (no hint), and an authenticated denial (no hint). It fails without the fix. ToolRunCommandTest passes; phpcs and phpstan are clean. The full suite is left to CI.