Page MenuHomePhabricator

🧹 Prevent the UseCase Validators leaking the Validation Validator's error contexts out of the Application namespace
Closed, ResolvedPublic

Description

The context array from the Application Validators is often passed directly into the UseCaseError that is thrown by a UseCase Validator - for example in the GetItemStatementsValidator. This results in the Application/Validation namespace effecting the error context the route handlers return.

Instead the UseCase Validators should declare context keys as constants and “rebuild” the context array when creating the UseCaseErrors to throw in order to keep the Application/Validation namespace isolated from the RouteHandlers.

Things to consider once task complete:

  • Should we create use case level validators for commonly validated request data?
  • Should we create namespaces for similar groups of use cases (e.g. Item / Property use cases) ?
    • Common use case validators could live in each of those namespaces

Event Timeline

Ollie.Shotton_WMDE renamed this task from Rebuilding contexts for "Validation Validators" to 🧹 Prevent the UseCase Validators leaking the Validation Validator's error contexts out of the Application namespace.Jul 13 2023, 4:17 PM
Ollie.Shotton_WMDE updated the task description. (Show Details)

Change 938273 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):

[mediawiki/extensions/Wikibase@master] REST: Add missing SetItemDescriptionValidator tests

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

Change 938275 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):

[mediawiki/extensions/Wikibase@master] REST: Improve the Use Case Validators

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

Change 938273 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add missing SetItemDescriptionValidator tests

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

Change 938275 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Improve the Use Case Validators

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

Change 939352 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):

[mediawiki/extensions/Wikibase@master] REST: Improve Use Case Validator Tests

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

Change 939352 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Improve Use Case Validator Tests

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

Change 939748 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):

[mediawiki/extensions/Wikibase@master] REST: PoC - modify UseCaseError context logic

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

Change 939748 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Modify UseCaseError context logic

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

Change 943570 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):

[mediawiki/extensions/Wikibase@master] REST: Add unit tests to `UseCaseErrorTest`

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

Change 943570 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add unit tests to `UseCaseErrorTest`

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

@Ifrahkhanyaree_WMDE: https://phabricator.wikimedia.org/project/view/6686/ got archived but this task tagged with the project is still opened. Should the task of this status be set to resolved?