Page MenuHomePhabricator

Attribution API: Handle non-200 responses
Closed, ResolvedPublic3 Estimated Story Points

Description

While creating Handler integration tests we've noticed the Attribution API has only a 'OK' response. There are multiple crash points that throw errors so we should catch these and return appropriate response.

  • If checkAccessPermission throws return a 403
  • If Assert::invariant( $pageIdentity !== null ) throws return a 404
  • If Assert::invariant( $page !== null ) throws return a 404
  • Introduce handler tests that cover these cases
  • Log the errors

Event Timeline

Notes from Estimation:

  • Verify that this is not already being handled by other content handlers. There are ~4 other handlers that make various checks, so make sure that it's not already covered by top level error handling.
    • More specific checks allow for more detailed/specific error messages and telemetry.
  • Add logging for the error (if it is not already handled)
HCoplin-WMF set the point value for this task to 3.Apr 9 2026, 4:03 PM

Change #1270438 had a related patch set uploaded (by Atieno; author: Atieno):

[mediawiki/extensions/WikimediaCustomizations@master] Attribution: Add handler tests

https://gerrit.wikimedia.org/r/1270438

Update on this being a blocker to launch::

The Attribution endpoint returns 404 for a missing page for example Missing page handled by the call to checkHasContent. The Asserts that happen earlier in the codebase are not fatal in Production(by default), only in development/test/debug mode so the local throws I had are a false alarm...However if in the future assertion failures were magically enabled in prod then we would have these crashes, but for now the "we don't raise 403 and 404" is technically not a blocker.

Change #1270438 merged by jenkins-bot:

[mediawiki/extensions/WikimediaCustomizations@master] Attribution: Add handler tests and 403, 404 logging

https://gerrit.wikimedia.org/r/1270438