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

Deserialization should not rely on classes with constructors having large parameter counts #390

Closed
3 of 5 tasks
Tracked by #598
dixler opened this issue Apr 15, 2022 · 7 comments · Fixed by #720
Closed
3 of 5 tasks
Tracked by #598
Assignees
Labels
area/sdks kind/enhancement Improvements or new features language/java resolution/fixed This issue was fixed
Milestone

Comments

@dixler
Copy link
Contributor

dixler commented Apr 15, 2022

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

Deserialization should not rely on classes with constructors having large parameter counts.

Code generation for Java SDK classes that need to be deserialized from protobuf currently relies on constructors with many parameters (one per desired property) internally. This breaks down when it hits hard limits on Java parameter counts.

Earlier when we worked around the problem of not being able to compile providers with large parameter counts, we introduced a special pathway in the SDK code generator for the special case of "jumbo" constructors. This does not completely solve the problem however. While you can construct these Jumbo objects, tryConvertObjectInner errors when facing them.

Desired complete fix would:

  • fix the deserializer in the Java SDK to not require one parameter per property in any method or constructor of the generated classes, so as to not hit the Java limit
  • fix the codegen to align with the deserializer expectations
  • remove branching on parameter count from codegen code
  • have no breaking changes for the users (it seems the problem can be solved internally)
  • fix or avoid "Converter::tryConvertObjectInner errors when calling jumbo constructors" found earlier

Affected area/feature

@dixler dixler added the kind/enhancement Improvements or new features label Apr 15, 2022
@dixler dixler mentioned this issue Apr 15, 2022
3 tasks
@pawelprazak
Copy link
Contributor

I'm curious, what was the error?

@dixler
Copy link
Contributor Author

dixler commented Apr 15, 2022

@pawelprazak
Copy link
Contributor

Hmm

Caused by: java.lang.IllegalArgumentException: Expected type 'io.pulumi.awsnative.s3.outputs.BucketWebsiteConfiguration' (annotated with 'io.pulumi.core.annotations.CustomType') to provide a constructor annotated with 'io.pulumi.core.annotations.CustomType$Constructor', and the parameter names in the annotation matching the parameters being deserialized. Constructor 'private io.pulumi.awsnative.s3.outputs.BucketWebsiteConfiguration()' expects parameter names of: '', but does not expect: 'indexDocument'. Unable to deserialize.

looks like unexpected parameter 'indexDocument' on parameter-less constructor

@dixler dixler added kind/bug Some behavior is incorrect or out of spec and removed kind/enhancement Improvements or new features labels Apr 16, 2022
@t0yv0 t0yv0 changed the title Converter::tryConvertObjectInner errors when calling jumbo constructors Deserialization should not rely on classes with constructors having large parameter counts May 31, 2022
@t0yv0 t0yv0 mentioned this issue May 31, 2022
40 tasks
@mikhailshilkov mikhailshilkov added language/java kind/enhancement Improvements or new features and removed kind/bug Some behavior is incorrect or out of spec labels Jun 1, 2022
@t0yv0 t0yv0 added this to the 0.74 milestone Jun 7, 2022
@mikhailshilkov mikhailshilkov modified the milestones: 0.74, 0.75 Jul 1, 2022
@pawelprazak
Copy link
Contributor

I've added jumbo custom type support to the SDK, it is already quite big (because of codegened test)
so it feel like I should do the codegen changes in a separate PR, WDYT?

@pawelprazak
Copy link
Contributor

pawelprazak commented Jul 11, 2022

I assume we don't want to break current providers, so I plan to remove the constructor-based code, after we release both the new codegen and regenerate all of the (affected) providers.

As a result, I plan to do as follows, in 4 stages:

There might be some additional cleanup needed in the codegen, after removal of the old mechanism, I'm not super familiar with this part of the codebase, but I anticipate this eventuality.

@t0yv0
Copy link
Member

t0yv0 commented Jul 11, 2022

Interesting.

  1. We are still in a position that we could roll out a breaking change if it makes things a lot easier. The workaround for users is relatively simple - they need to update both SDK and providers.

  2. Providers are migrating to https://github.com/pulumi/pulumi-azuread/tree/master/sdk/java etc so we need to keep merging changes to main and logging in CHANGELOG_PENDING so that if there are changes to codegen that are going to result in breaking provider changes they're reflected in the changelog. They will be released eventually.

  3. after removal of the old mechanism, I'm not super familiar with this part of the codebase - it should be simple to do (a few hours) so I would love to see it included.

pawelprazak added a commit that referenced this issue Jul 19, 2022
@t0yv0
Copy link
Member

t0yv0 commented Jul 19, 2022

Let's create a follow-up issue (s) for cleanup issues, and consider this done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sdks kind/enhancement Improvements or new features language/java resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants