Conversation
LinoGiger
commented
Mar 19, 2026
PR Review: Feat/RAPID-7283 Fix or Filter AudienceOverall a clean, well-scoped PR. Changes align with existing patterns (lazy init, TYPE_CHECKING imports). A few observations: or_filter.py bug fix - The .to_dict() addition is correct. OneOf discriminated union models in Pydantic-based generated code do not recursively serialize nested instances — plain dicts are required. Real bug fix, correct approach. Naming inconsistency: _add_rapid_example() - The method internals were updated to use IExamplePayload/IExampleTruth but the method name still says 'rapid'. Consider renaming to _add_example() for consistency with the migration. Fragile conversion via from_dict(to_dict()) - The comment says both types are structurally identical, which is true today. But if the backend schemas ever diverge, this breaks silently at runtime with no compile-time signal. A round-trip unit test would catch future drift. Also worth guarding: IExamplePayload.from_dict() can return None — consider raising a ValueError with a helpful message if that happens. api.mustache deep object support - The hasattr(_param_val, 'to_dict') duck-typing approach is reasonable for generated code. Worth documenting in a comment that this pattern is intentional so future template maintainers don't remove it. find_orders() simplification - The new flat parameter interface is much cleaner than the previous 7-import nested QueryModel. FlowGetNameParameter is a slightly odd name for an order name filter, but that appears to be a backend naming decision. Missing tests - No tests cover: OrFilter nested serialization (the bug fix), the IRapidPayload->IExamplePayload conversion in _add_rapid_example, or the new find_orders() query params. A regression test for the OrFilter fix would be especially valuable. Minor - The preview_order_endpoint_input import line in rapidata_order.py is quite long compared to the rest of the file. Generated with Claude Code |
PR Review: Fix
|
|
PR Review: Fix OrFilter serialization for audience filters The fix is correct and well-targeted. Root cause confirmed The asymmetry between AndFilter and OrFilter stems from the generated API models:
AndFilter worked by accident (strongly typed list), while OrFilter silently produced broken output. The pre-converting-to-dict workaround in or_filter.py is correct given the generated model constraints. NotFilter does not need the same fix since IAudienceFilterNotAudienceFilter.filter is typed as IAudienceFilter with an explicit .to_dict() call in its serializer. Observations
Summary: The fix resolves the bug correctly. Suggestions: (1) add a comment explaining the inline import in the mapper, (2) consider fixing the OpenAPI spec so OrFilter.filters is strongly typed, (3) add a unit test for OrFilter serialization. Generated with Claude Code |