[BUG](codegen) An optional union entry point generates without its None arm

Open
#865 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start by reading the codegen path around is_union_alias and the alias and RootModel handling for discriminated unions; the issue names these entry points but no files or tests. Trace how | None is handled and find the related tests before making a change. Done means both entry points reject the optional union with an error naming the entry point and class, and generated checks and pages no longer describe the bare alias as only A or B.

Written by the indexing model from the issue text.

Description

Annotated[A | B | None, Field(discriminator=...)] as a bare alias entry point generates as a union of A and B: is_union_alias looks through | None, so the None arm is dropped and the generated checks and pages say every row is an A or a B. The same annotation as a RootModel's root raises UnsupportedUnionError from the alias path. A feature's row cannot be None, so both should raise an error naming the entry point and the class.

Dominant language
Python
Stars
219
Forks
20
Avg merge
1d 21h
Merged PRs (30d)
37

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OvertureMaps/schema

All issues in OvertureMaps/schema

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.