Skip to content

Conversation

@peter-zhong-replit
Copy link
Contributor

@peter-zhong-replit peter-zhong-replit commented Jul 17, 2025

Why

The encode_type function was incorrectly propagating the RiverError base class to all nested types when generating error schemas. This meant that if an error type had nested object properties (e.g., a field containing user details or metadata), those nested objects would also inherit from RiverError instead of BaseModel. This is incorrect because only the top-level error types should inherit from RiverError - nested properties are just data structures, not errors themselves.

What changed

Modified the encode_type function to pass "BaseModel" instead of the current base_model value when recursively processing object properties (line 538). This is done conditionally only when the current base_model is "RiverError". The fix ensures that:
Top-level error types and union members of error types continue to inherit from RiverError
Nested properties within those error types inherit from BaseModel
All other base model types ("TypedDict", "BaseModel") maintain their existing behavior unchanged

@peter-zhong-replit peter-zhong-replit requested a review from a team as a code owner July 17, 2025 03:49
@peter-zhong-replit peter-zhong-replit requested review from jackyzha0 and removed request for a team July 17, 2025 03:49
@peter-zhong-replit peter-zhong-replit merged commit 7e9519f into main Jul 17, 2025
4 checks passed
@peter-zhong-replit peter-zhong-replit deleted the peter/code-gen-river-error branch July 17, 2025 20:51
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.

5 participants