Skip to content

page_content_change: retry requests on missing content

Gmodena requested to merge page_change-add-badrevision into main

This MR improves error handling for revisions that trigger a "missing content" response from the Mediawiki Action API.

See https://wikitech.wikimedia.org/wiki/MediaWiki_Event_Enrichment#mediawiki.page_content_change_semantics for mode details on this error semantic.

This MR introduces two named exceptions to handle:

  • lagging database replica errors (MediaWikiApiDatabaseReplicaLagError).
  • generic missing content resulting in "badrevids" payloads (MediaWikiApiMissingContentError).

Both errors are re-tried and if not resolved forwarded to the error topic. The exception name will be set to the error_type field of errors. tests/test_page_content_change.py gives an example of how these errors can be filtered by clients:

if errored_event["revision"]["rev_id"] == 2147483647:
    assert event["error_type"] == "MediaWikiApiMissingContentError"
elif errored_event["revision"]["rev_id"] == 12345:
    assert event["error_type"] == "MediaWikiApiDatabaseReplicaLagError"

While named exceptions are considered an anti-pattern and not Pythonic, I think they will help consumers of the error topic to filter error types.

This MR reverts back CI changes for coverage reporting in Gitlab. See the bug report in https://phabricator.wikimedia.org/T340195 for details.

Bug: T309699

Bug: T340195

cc / @dcausse @tchin @otto @milimetric

Edited by Gmodena

Merge request reports