fix(CFT-223): Handle empty list to dict conversion for user_properties #23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the "eternal KBC bug" (CFT-223) where the Keboola platform converts empty JSON objects
{}to empty arrays[]in configuration parameters. When users leaveuser_propertiesempty, the platform preprocessing converts it from{}to[], but the Configuration dataclass expected a dictionary, causing dacite validation to throw aWrongTypeError.Changes:
user_propertiestype hint to accept bothdict[str, object] | listso dacite can deserialize either type__post_init__method to Configuration class that converts empty lists to empty dictsUserExceptionwith a clear error messageReview & Testing Checklist for Human
config.jsoncontains"user_properties": [], dacite.from_dict() in component.py correctly passes the list to the dataclass and__post_init__converts it to{}.user_propertiesin the UI and verify the component runs without theWrongTypeError._merge_user_parameters()(line 119-131 in component.py) receives a dict after the conversion.Recommended test plan:
runtime.tagconfigurationuser_propertiesNotes
{}to[]conversion is expected__post_init__as requestedLink to Devin run: https://app.devin.ai/sessions/0dcae42daa1342af93cdf52c06e42d6c
Requested by: [email protected] (@davidesner)