Skip to content

Fix bug for PydanticSchemaGenerationError in rest_api#1544

Closed
grapemix wants to merge 1 commit intobareos:masterfrom
grapemix:fix_restapi
Closed

Fix bug for PydanticSchemaGenerationError in rest_api#1544
grapemix wants to merge 1 commit intobareos:masterfrom
grapemix:fix_restapi

Conversation

@grapemix
Copy link

This patch locks down the pip package version to prevent the backward compatibility problem from pydantic 2.x.

Since pydantic 2.x has been released, users will see the following error without this patch:

pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'bareos_restapi.models.bareosACL'>. Set arbitrary_types_allowed=True in the model_config to ignore this error or implement __get_pydantic_core_schema__ on your type to fully support it.

All the versions are from pip freeze from my Docker.

Thank you for contributing to the Bareos Project!

Backport of PR #0000 to bareos-2x (remove this line if this is no backport; for backport use cherry-pick -x)

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • [] Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • [N/A] Check backport line
  • [N/A] Required backport PRs have been created
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
Tests

Tested in my Docker only

This patch locks down the pip package version to prevent the backward
compatibility problem from pydantic 2.x.

Since pydantic 2.x has been released, users will see the following
error without this patch:

pydantic.errors.PydanticSchemaGenerationError: Unable to generate
pydantic-core schema for <class 'bareos_restapi.models.bareosACL'>. Set
`arbitrary_types_allowed=True` in the model_config to ignore this error
or implement `__get_pydantic_core_schema__` on your type to fully
support it.
@joergsteffens
Copy link
Member

Thank you for your contribution and for pointing out this issue. While this approach will work for most environments, it would require changes to our automated systemtest environment, as the content of the requirements.txt file is used to determine if a test is performed on a platform (if a platform does not meet the requirements, the test is skipped, therefore the restapi systemtest is skipped on all platforms with this PR).
While testing your PR, I checked the root cause and created #1546.
Do you mind to check, if this would also solve your issues? If yes, I'd prefer to integrate #1546.

@joergsteffens
Copy link
Member

Problem solved by #1546. Therefore this PR is no longer required. Thank you for pointing this problem out.

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