Skip to content

Conversation

@davidesner
Copy link
Contributor

Summary

Fixes the "eternal KBC bug" (CFT-223) where the Keboola platform converts empty JSON objects {} to empty arrays [] in configuration parameters. When users leave user_properties empty, the platform preprocessing converts it from {} to [], but the Configuration dataclass expected a dictionary, causing dacite validation to throw a WrongTypeError.

Changes:

  • Updated user_properties type hint to accept both dict[str, object] | list so dacite can deserialize either type
  • Added __post_init__ method to Configuration class that converts empty lists to empty dicts
  • Non-empty lists raise UserException with a clear error message
  • Added 5 unit tests covering: empty list conversion, non-empty list rejection, dict unchanged, empty dict unchanged, and default value

Review & Testing Checklist for Human

  • Verify dacite integration: The unit tests only test the Configuration dataclass directly. Verify that when config.json contains "user_properties": [], dacite.from_dict() in component.py correctly passes the list to the dataclass and __post_init__ converts it to {}.
  • Test in Keboola environment: Create a configuration with empty user_properties in the UI and verify the component runs without the WrongTypeError.
  • Verify downstream code: Confirm that _merge_user_parameters() (line 119-131 in component.py) receives a dict after the conversion.

Recommended test plan:

  1. Deploy this branch to a test environment using runtime.tag configuration
  2. Create a Custom Python component configuration with empty user_properties
  3. Run the component and verify it initializes successfully
  4. Verify user scripts can access parameters via CommonInterface

Notes

  • This is defensive programming for known platform behavior - the platform team has confirmed this {} to [] conversion is expected
  • The fix is localized to the Configuration dataclass layer using __post_init__ as requested

Link to Devin run: https://app.devin.ai/sessions/0dcae42daa1342af93cdf52c06e42d6c
Requested by: [email protected] (@davidesner)

The Keboola platform converts empty JSON objects {} to empty arrays []
in configuration parameters. This fix adds defensive programming to
handle this known platform behavior.

Changes:
- Add __post_init__ method to Configuration class to convert empty
  lists to empty dicts for user_properties
- Update type hint to accept both dict and list types
- Add comprehensive test coverage for the fix

Co-Authored-By: [email protected] <[email protected]>
@linear
Copy link

linear bot commented Dec 16, 2025

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@davidesner davidesner marked this pull request as ready for review December 17, 2025 07:24
@davidesner davidesner requested a review from soustruh December 17, 2025 07:26
Copy link
Contributor

@soustruh soustruh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@soustruh soustruh merged commit 870c843 into main Dec 17, 2025
8 checks passed
@soustruh soustruh deleted the devin/CFT-223-1765869288 branch December 17, 2025 11:12
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