Skip to content

Bug 2085028 - log_user_request logs empty request_url/user_agent and server 'web' for native Mojo API routes - #2795

Open
Xzzz wants to merge 3 commits into
mozilla:masterfrom
Xzzz:bug-2085028
Open

Xzzz wants to merge 3 commits into
mozilla:masterfrom
Xzzz:bug-2085028

Conversation

@Xzzz

@Xzzz Xzzz commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Makes Bugzilla->log_user_request read the request from the Mojo controller on native Bugzilla::API::V1 routes. It read it from Bugzilla->cgi, whose environment is only emulated for the legacy .cgi routes (Bugzilla/App/Controller/CGI.pm), so user_request_log rows from native routes got an empty request_url and user_agent, a default GET method and server web.

Follow-up of 2081856, whose GET /rest/bug/<id>/attachment is the first native route that logs. Needed before 2081860, which moves bug-get logging to the native routes.

Changes

  • Under USAGE_MODE_MOJO_REST, take the URL path, method and user agent from the Mojo request, and log server rest. The legacy routes are unchanged.
  • As with the legacy REQUEST_URI, the logged URL is the path without the query string.
  • New t/app-log-user-request.t: logs from a test route and checks the whole row.

Test plan

  • Enable log_user_requests, then GET /rest/bug/<id>/attachment with an API key: the new user_request_log row has the request path, GET, the client's user agent and server rest
  • Open an attachment via attachment.cgi: the row still has server web

References

…server 'web' for native Mojo API routes

The CGI environment is only emulated for the legacy .cgi routes, so on native Bugzilla::API::V1
routes log_user_request logged an empty URL and user agent, a default GET method and server 'web'.
Read them from the Mojo request under USAGE_MODE_MOJO_REST instead.

@dklawren dklawren left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM r=dkl

@dklawren

Copy link
Copy Markdown
Collaborator

Please fix:

Use of uninitialized value $prefix in concatenation (.) or string at Bugzilla/CGI.pm line 669.
t/buglist-series-idor.t ...................... ok
# Variables::ProhibitPunctuationVars: Got 111 violation(s).  Expected no more than 110.

#   Failed test 'Test::Perl::Critic::Progressive'
#   at t/critic.t line 24.
# Looks like you failed 1 test of 1.
t/critic.t ................................... 
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests 

@Xzzz

Xzzz commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Fixed both in two commits:

  • 7e9af99: the $prefix warning came from buglist.cgi using namedcmd unchecked for remaction=runseries. The test URL in t/buglist-series-idor.t doesn't send it, so it now falls back to bugs
  • b317e5e: the extra critic violation came from "_$$" in extensions/BMO/bin/export_bmo_etl.pl (from Bug 2080901 on master). CI runs on the merge with master, so it showed up here. Replaced with $PROCESS_ID from English

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants