Commit 7e9519f
authored
Error codegen (#162)
# 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 unchanged1 parent c5e05ce commit 7e9519f
File tree
2 files changed
+5
-5
lines changed- src/replit_river/codegen
- tests/v1/codegen/snapshot/snapshots/test_unknown_enum/enumService
2 files changed
+5
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | | - | |
| 538 | + | |
539 | 539 | | |
540 | 540 | | |
541 | 541 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
119 | | - | |
| 118 | + | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
0 commit comments