Skip to content

🐛(validation) replace TypeErrors with ValueErrors#632

Merged
MYilFun00 merged 2 commits into
openfun:mainfrom
piptouque:fix_validation_type_error
Jul 6, 2026
Merged

🐛(validation) replace TypeErrors with ValueErrors#632
MYilFun00 merged 2 commits into
openfun:mainfrom
piptouque:fix_validation_type_error

Conversation

@piptouque

@piptouque piptouque commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Purpose

[TypeErrors are not supported as validation errors by Pydantic](https://pydantic.dev/docs/validation/latest/concepts/validators/ #raising-validation-errors).
So Pydantic won't encapsulate them in a ValidationError.

Proposal

We replace them with ValueErrors, which work as expected.

  • Replaced TypeErrors with ValueErrors in Pydantic models
  • Updated tests
  • Updated CHANGELOG.md

piptouque and others added 2 commits June 15, 2026 11:02
`TypeError`s are not supported as validation errors by Pydantic:
it won't encapsulate them in a ValidationError.
We replace them with `ValueError`s, which work
as expected.

see: https://pydantic.dev/docs/validation/latest/concepts/validators/
\#raising-validation-errors
…_error

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	CHANGELOG.md

@MYilFun00 MYilFun00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. TypeErrors raised inside validators are not caught by Pydantic
as validation errors, so they were never wrapped in a ValidationError
replacing them with ValueErrors is the correct fix and makes the models
raise as expected.

Reviewed the change scope: backends/lrs/base.py, models/xapi/base/common.py
and the two updated test files. Validated locally on top of the latest main
(branch rebased/merged, CHANGELOG conflict resolved): the xapi validation
suite passes (124 passed) and the full CI is green.

Thanks @piptouque!

@MYilFun00 MYilFun00 merged commit 5116110 into openfun:main Jul 6, 2026
22 checks passed
MYilFun00 added a commit to piptouque/ralph that referenced this pull request Jul 6, 2026
Reconcile with main (openfun#632, openfun#634, openfun#635) and resolve CHANGELOG conflict.

Co-authored-by: Cursor <cursoragent@cursor.com>
MYilFun00 added a commit to piptouque/ralph that referenced this pull request Jul 6, 2026
Reconcile with main (openfun#632, openfun#634, openfun#635) and resolve CHANGELOG conflict.
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.

2 participants