Skip to content

[pydantic > 2] xAPI extensions cannot hold empty strings #553

@Leobouloc

Description

@Leobouloc

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 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions