You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The migration to pydantic v2 will introduce a regression with respect to the xAPI specification. Following the migration, xAPI statements cannot contain empty string values even in an "extensions" field. This behavior is contrary to the specification and must be reverted.
The reason for the regression is that model_config has str_min_length=1, which previously (pydantic <2) did not apply to values defined as dicts (when setting an extension) but now (pydantic >2) does.
One solution could be to create a custom class (RootModel[Dict] ?) for extensions with a custom config.
TODO:
Check that LanguageMap = Dict[LanguageTag, NonEmptyStrictStr] is not used in extensions (as it forces a non empty string
Add "" to values in test_models_xapi_base_statement_with_valid_null_values
The text was updated successfully, but these errors were encountered:
Leobouloc
changed the title
[Pydantic > 2] xAPI extensions cannot hold empty strings
[pydantic > 2] xAPI extensions cannot hold empty strings
Jan 24, 2024
Bug Report
The migration to pydantic v2 will introduce a regression with respect to the xAPI specification. Following the migration, xAPI statements cannot contain empty string values even in an "extensions" field. This behavior is contrary to the specification and must be reverted.
The reason for the regression is that
model_config
hasstr_min_length=1
, which previously (pydantic <2) did not apply to values defined as dicts (when setting an extension) but now (pydantic >2) does.One solution could be to create a custom class (
RootModel[Dict]
?) for extensions with a custom config.TODO:
LanguageMap = Dict[LanguageTag, NonEmptyStrictStr]
is not used in extensions (as it forces a non empty string""
to values intest_models_xapi_base_statement_with_valid_null_values
The text was updated successfully, but these errors were encountered: