Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Pydantic, removal of alias breaks code #2187

Open
2 tasks done
black-snow opened this issue Feb 17, 2025 · 6 comments
Open
2 tasks done

[BUG] Pydantic, removal of alias breaks code #2187

black-snow opened this issue Feb 17, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@black-snow
Copy link
Contributor

black-snow commented Feb 17, 2025

Describe the bug.

Following up on #2174 because the cause seems to be the same changes - especially e9e46b3#diff-e4313dba292240670e96b378fd98fa02d9dd6a0e7b96153c03787ee71904339fL52

Comparing the freshly generated models with my existing ones, I see that

queue_name: str = Field(description='''The name of the targeted queue''', alias='''queueName''')

becomes

queue_name: str = Field(description='''The name of the targeted queue''')

with

            queueName:
              type: string
              minLength: 1
              description: "The name of the targeted queue

So the alias got removed. Sadly, this ain't no no-op change but a change in behaviour. Many tests fail now, especially when I model_validate_json(some_json).

This seems to be the corresponding PR. Sadly, the 4.0.0 release just says "breaking changes!" but doesn't list them. Overall, this is a bad experience - especially since I don't use modelina directly but asyncAPI cli, which just upgraded to 4.x in a non-major update. So I bump the CLI expecting things to just work but stuff keeps blowing up :/

Expected behavior

  • alias should not have been removed (I don't understand the reason in the PR) OR
  • 4.0.0 release should list this change (and ideally what do do about it) and then
    • asyncAPI cli should not just minor or patch change customer-facing breaking changes

Screenshots

How to Reproduce

  1. use "@asyncapi/cli": "2.14.1"
  2. generate model from a schema with some camelCase property
  3. note the alias
  4. use "@asyncapi/cli": "2.16.0" or later
  5. generate model from a schema with some camelCase property
  6. note the alias is missing
  7. try to model_validate_json() from a string with said camelCase property

🥦 Browser

Mozilla Firefox

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

Yes I am willing to submit a PR!

@black-snow black-snow added the bug Something isn't working label Feb 17, 2025
@black-snow
Copy link
Contributor Author

@memdal could you elaborate why alias was removed?

@jonaslagoni
Copy link
Member

Looking at https://github.com/asyncapi/modelina/pull/2111/files#diff-e4313dba292240670e96b378fd98fa02d9dd6a0e7b96153c03787ee71904339fL60 that is definitely not supposed to be removed.

Do you mind raising a PR @black-snow?

@black-snow
Copy link
Contributor Author

@jonaslagoni thanks for checking. Sure, will do as soon as I can.

Is there a list of breaking changes with 4.x hidden anywhere? How can we prevent surprising breaking changes in the future - especially with the asyncAPI cli?

@jonaslagoni
Copy link
Member

Every breaking change is always described in the migration doc: https://github.com/asyncapi/modelina/blob/master/docs/migrations/version-3-to-4.md

If nothing is described and is broken, it is an unintended breaking change for sure. However, it looks like there was some stuff about alias python: https://github.com/asyncapi/modelina/blob/master/docs/migrations/version-3-to-4.md#pydantic-now-follows-v2-instead-of-v1

Does it make sense to you?

@black-snow
Copy link
Contributor Author

Ah great, so we have a guide - we should probs link this to the 4.0.0 release notes then.

@jonaslagoni
Copy link
Member

jonaslagoni commented Feb 18, 2025

Good idea, done 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants