Skip to content

fix: improve error handling in WorldBankOKRRecord model validation#147

Open
lpi-tn wants to merge 1 commit into
mainfrom
Fix/world-wank-okr-model
Open

fix: improve error handling in WorldBankOKRRecord model validation#147
lpi-tn wants to merge 1 commit into
mainfrom
Fix/world-wank-okr-model

Conversation

@lpi-tn

@lpi-tn lpi-tn commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

This pull request improves the robustness and test coverage of the WorldBankOKRRecord model by adding validation for missing or malformed XML fields and expanding the test suite to cover these scenarios. The main changes are grouped into enhanced validation logic and expanded test coverage.

Enhanced validation logic:

  • Updated _extract_file_grp in world_bank_okr.py to raise a ValueError with a descriptive message if the fileGrp or FLocat tags are missing from the XML input, improving error reporting for malformed documents.
  • Modified _extract_identifiers to raise a ValueError when no URI identifier is found, ensuring required fields are present.
  • Changed error handling in support_xml_extractor to raise a ValueError with clear messages if title or abstract tags are missing, replacing custom exceptions for consistency and clarity. [1] [2]

Expanded test coverage:

  • Added new tests in test_world_bank_okr.py to verify that the model correctly raises ValidationError when required XML fields (fileGrp, FLocat, identifier, title, abstract) are missing or empty, ensuring the validation logic works as intended.
  • Imported ValidationError from pydantic in the test file to support the new test cases.

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.

1 participant