Page MenuHomePhabricator

[BLOCKED] Add response validation check to end-to-end testing on MediaFile MW Rest API endpoint
Open, MediumPublic1 Estimated Story Points

Description

Description

We perform end-to-end testing as part of the CI pipeline process using Mocha. For every endpoint in the MediaWiki REST API, we need to add a check that verifies the returned response matches the public API specifications. This will allow us to automatically detect, capture, and surface instances where the endpoint behavior does not match what is documented in the response body, which increases API stability, improving the MW API developer experience.

Problem statement

The main defense that we have against spec deviation is ensuring that undocumented changes don’t make it into production in the first place. We need to catch variation in the spec vs actual endpoint behavior as part of the release process as a way to ensure documentation accuracy and prevent accidental changes. By introducing spec validation as part of end-to-end testing for every endpoint, we can improve stability for our API.

Conditions of acceptance

  • Update Mocha tests to utilize the reusable methods for fetching JSON schema response and comparing it against the php response using the validation method for all 'MediaFile' endpoints:
    • GET /file/{title}
  • Perform updates that force the test to fail; verify that it will trigger a CI error.
  • Verify that the test works across different HTTP responses for each endpoint.
  • Demonstrate the functionality to the team.

Details

Related Changes in Gerrit:

Event Timeline

HCoplin-WMF set the point value for this task to 3.

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

[mediawiki/core@master] mocha: Test Media file endpoint

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

OWresch-WMF renamed this task from Add response validation check to end-to-end testing on MediaFile MW Rest API endpoint to [BLOCKED] Add response validation check to end-to-end testing on MediaFile MW Rest API endpoint.May 12 2025, 3:17 PM

Change #1126009 abandoned by Atieno:

[mediawiki/core@master] mocha: Test Media file endpoint

Reason:

Cleanuo. Can review when it comes up later

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

@Atieno do you happen to remember why this is blocked?

Daniel's code review comment on t[[ https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1126009 | he attached (abandoned) patch ]] sums it up pretty well:

I don't really see an easy wayto achieve this, since there is no media file available on the target wiki per default. We'll have to programmatically upload a media file first, probably using the action API. It would have to use a randomized name too...

Basically, this is a hard thing to test and our normal testing fixtures aren't helpful in this case.

Aklapper added a subscriber: • Atieno.

Removing inactive assignee - please do so as part of team offboarding processes.