Skip to content

Fix codegen crashes for intersection types and complex list inner types#172

Merged
daweifeng-replit merged 3 commits intomainfrom
dawei/fix-intersection-type
Feb 6, 2026
Merged

Fix codegen crashes for intersection types and complex list inner types#172
daweifeng-replit merged 3 commits intomainfrom
dawei/fix-intersection-type

Conversation

@daweifeng-replit
Copy link
Contributor

@daweifeng-replit daweifeng-replit commented Feb 6, 2026

Why

Codegen fails when a schema contains intersection types (allOf) or lists with complex inner types (e.g. list[dict[str, Any]]). Both crash with Complex type must be put through render_type_expr! or Unexpected expression when expecting a type name: DictTypeExpr(...) because TypeName objects are used directly in f-strings or passed to ensure_literal_type which only accepts simple TypeName values.

What changed

  • Fix TypeName.__str__() crash in the RiverIntersectionType encoder by wrapping encoder_name with render_literal_type(), matching the existing pattern used by RiverUnionType (line 625) and RiverConcreteType (line 654)
  • Fix ensure_literal_type crash when a list's inner type is a complex expression (e.g. list[dict[str, Any]]) by guarding the ListTypeExpr match to only enter the encoding branch for TypeName inner types, falling through to list(x) for composite types that don't need encoding

Test plan

Describe what you did to test this change to a level of detail that allows your reviewer to test it

@daweifeng-replit daweifeng-replit requested a review from a team as a code owner February 6, 2026 01:40
@daweifeng-replit daweifeng-replit requested review from jackyzha0 and removed request for a team February 6, 2026 01:40
@daweifeng-replit daweifeng-replit added the bug Something isn't working label Feb 6, 2026
@daweifeng-replit daweifeng-replit merged commit bd88e45 into main Feb 6, 2026
3 checks passed
@daweifeng-replit daweifeng-replit deleted the dawei/fix-intersection-type branch February 6, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants