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

data class default values don't apply after resolvers #460

Open
pschichtel opened this issue Nov 5, 2024 · 1 comment
Open

data class default values don't apply after resolvers #460

pschichtel opened this issue Nov 5, 2024 · 1 comment

Comments

@pschichtel
Copy link

pschichtel commented Nov 5, 2024

I just attempted to upgrade our hoplite setup 2.7.5 to 2.9.0. Part of that is the migration from preprocessors to resolvers, which seemed fairly straight forward. We had one processor that replaces ${...} variables and one that removes null-valued fields from map values.

The env preprocessor can produce null values in cases, where the environment variable is not set, so the second preprocessor's job is to get rid of these fields completely. This was necessary to get kotlin's data class parameter default values working.

Porting the preprocessors 1:1 over to the resolver API was as simple as replacing the process method signature with the resolve signature and fixing some recursive calls, but the problem now is, that non-null optional fields in data classes fail to decode, because it receives a null value.

So my issue is: How can I implement a resolver that produces null/undefined values that are then correctly mapped to parameter default values?

@pschichtel
Copy link
Author

pschichtel commented Feb 14, 2025

@sksamuel To me it looks like the DataClassDecoder still attempts to decode the field's node value even when the resolver returns Undefined, instead of applying the default value from the data class.

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

No branches or pull requests

1 participant