Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Fix intersection of shape defaults #1950

Conversation

jshearer
Copy link
Contributor

@jshearer jshearer commented Feb 19, 2025

Description:

We weren't correctly narrowing the default of intersected shapes. For example, if we intersected one shape like

{
    "type": ["string", "null"],
    "default": "null"
}

with another shape like

{
    "type": "string"
}

We'd end up with a shape of

{
    "type": "string",
    "default": null
}

Which isn't correct, as when we try to actually emit a document for this shape that's missing the field in question and provide its default value of null, that will subsequently fail to validate against the schema.

Also adds a test to confirm Dekaf's proper handling of schemas like this, which is why this branch is ontop of that one.

Fixes #1944


This change is Reviewable

@jshearer jshearer force-pushed the jshearer/fix_default_shape_intersection branch from 1499d02 to 4a978b4 Compare February 19, 2025 20:15
@jshearer jshearer requested a review from psFried February 20, 2025 18:49
We weren't correctly narrowing the default of intersected shapes. For example, if we intersected one shape like
```json
{
    "type": ["string", "null"],
    "default": "null"
}
```

with another shape like
```json
{
    "type": "string"
}
```

We'd end up with a shape of
```json
{
    "type": "string",
    "default": null
}
```

Which isn't correct, as when we try to actually emit a document for this shape that's missing the field
in question and provide its default value of null, that will subsequently fail to validate against the schema.

Fixes #1944
@jshearer jshearer force-pushed the jshearer/fix_default_shape_intersection branch from 4a978b4 to 819fb98 Compare February 20, 2025 21:31
@jshearer jshearer changed the base branch from master to jshearer/dekaf_testing_and_fix_default_intersection February 20, 2025 21:32
Copy link
Member

@psFried psFried left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jshearer jshearer merged commit f6cc7b1 into jshearer/dekaf_testing_and_fix_default_intersection Feb 21, 2025
6 checks passed
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.

Fix intersected shapes having possibly invalid defaults
2 participants