Improve error messages when json schema validation fails (Pydantic discriminators)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start with declarative_component_schema.py, especially SimpleRetriever.selector and the requester union shown in the issue. Inspect the related union models and their discriminator fields, then validate representative manifests to confirm failures identify missing or unexpected fields instead of producing large anyOf errors.
Written by the indexing model from the issue text.
Description
We get really noising and difficult to parse error messages when manifests don't successfully validate against the json schema.
JSON Schema (and Pydantic) have a feature called "discriminator" which can help with this:
https://docs.pydantic.dev/latest/concepts/unions/#discriminated-unions
When Union validation fails, error messages can be quite verbose, as they will produce validation errors for each case in the union. This is especially noticeable when dealing with recursive models, where reasons may be generated at each level of recursion. Discriminated unions help to simplify error messages in this case, as validation errors are only produced for the case with a matching discriminator value.
Today: we get a huge error of the input not matching one of n "anyOf" conditions, which could be tens or hundreds of lines of error, without explicitly naming the field that was extra or missing.
Afterwards: we would get an error like field 'foo' is missing or unexpected field 'food' field
Sample code from the docs:
class Model(BaseModel):
pet: Cat | Dog | Lizard = Field(discriminator='pet_type')
n: int
Taking our SimpleRetriever.selector field, for example:
class SimpleRetriever(BaseModel):
...
requester: Union[CustomRequester, HttpRequester] = Field(
...,
description="Requester component that describes how to prepare HTTP requests to send to the source API.",
)
We'd update as follows to declare discriminator:
class SimpleRetriever(BaseModel):
...
requester: Union[CustomRequester, HttpRequester] = Field(
...,
description="Requester component that describes how to prepare HTTP requests to send to the source API.",
discriminator="type",
)
- Dominant language
- Python
- Stars
- 27
- Forks
- 56
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 30
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from airbytehq/airbyte-python-cdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
airbytehq/airbyte-python-cdk#1080 ·
Maintainers usually reply within 1 day
-
community
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
airbytehq/airbyte-python-cdk#782 ·
Maintainers usually reply within 1 day
-
community
Difficulty 5/5 Over a week Newbie friendliness 35/100
airbytehq/airbyte-python-cdk#1148 · 1 comment ·
Maintainers usually reply within 1 day
-
community
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
airbytehq/airbyte-python-cdk#1146 · 1 comment · 3 reactions ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
airbytehq/airbyte-python-cdk#1120 · 2 comments ·
Maintainers usually reply within 1 day
All issues in airbytehq/airbyte-python-cdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
WingedGuardian/GENesis-AGI#3375 ·
Maintainers usually reply within 1 day
-
curriculum documentation quality
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
githubnext/gh-aw-workshop#4601 ·
Maintainers usually reply within 1 day
-
approved Good First Issue scope: docs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
hiero-ledger/hiero-sdk-python#2730 · 3 comments ·
Maintainers usually reply within 1 day