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

SAT: Relax checking of oneOf common property and allow optional default keyword additional to const keyword #16172

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

grubberr
Copy link
Contributor

@grubberr grubberr commented Aug 31, 2022

Signed-off-by: Sergey Chvalyuk grubberr@gmail.com

What

We have requirement for all oneOf common properties to use only const keyword without default and enum keywords like this:

"option_title": {
  "type": "string",
  "const": "OAuth Credentials"
}

"option_title": {
  "type": "string",
  "const": "PAT Credentials",
}

BUT new pydentic==1.10.0 after this PR pydantic/pydantic#4152
started to generate json-schemas with default keyword like this:

"option_title": {
  "type": "string",
  "const": "OAuth Credentials",
  "default": "OAuth Credentials"
}

"option_title": {
  "type": "string",
  "const": "PAT Credentials",
  "default": "PAT Credentials",
}

How

I propose to be compatible with pydantic>=1.10.0 and not forbid default keyword in such common properties.

Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
@grubberr grubberr changed the title allow 'default' in oneOf with 'const' SAT: Relax checking of oneOf common property and allow optional default keyword additional to const keyword Aug 31, 2022
@grubberr grubberr self-assigned this Aug 31, 2022
@sherifnada
Copy link
Contributor

@grubberr can we skip the pydantic major version upgrade for now? I don’t know the impact of allowing default on OneOf in the UI

@grubberr
Copy link
Contributor Author

grubberr commented Aug 31, 2022

I have put this PR on-hold until we understand how to be with new pydantic==1.10.0
and default keyword in common oneOf property

@grubberr grubberr requested a review from a team as a code owner September 1, 2022 11:34
@github-actions github-actions bot added the CDK Connector Development Kit label Sep 1, 2022
@sherifnada
Copy link
Contributor

@grubberr is there a way to modify pydantic behavior instead? It seems like the wrong choice to modify all of the Airbyte Protocol expectations because a python library changed an implementation detail.

My understanding is that this will cause a suboptimal UI experience. Randomly selecting @tealjulia to confirm. Would adding the enum keyword to the oneOf blocks cause issues in the Ui?

Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
@airbytehq airbytehq deleted a comment from github-actions bot Sep 6, 2022
@airbytehq airbytehq deleted a comment from github-actions bot Sep 6, 2022
@airbytehq airbytehq deleted a comment from github-actions bot Sep 6, 2022
@airbytehq airbytehq deleted a comment from github-actions bot Sep 6, 2022
@airbytehq airbytehq deleted a comment from github-actions bot Sep 6, 2022
@airbytehq airbytehq deleted a comment from github-actions bot Sep 6, 2022
@grubberr
Copy link
Contributor Author

grubberr commented Sep 6, 2022

/test connector=bases/source-acceptance-test

🕑 bases/source-acceptance-test https://github.com/airbytehq/airbyte/actions/runs/3000543214
✅ bases/source-acceptance-test https://github.com/airbytehq/airbyte/actions/runs/3000543214
No Python unittests run

Build Passed

Test summary info:

All Passed

@airbytehq airbytehq deleted a comment from github-actions bot Sep 6, 2022
@airbytehq airbytehq deleted a comment from github-actions bot Sep 6, 2022
@grubberr
Copy link
Contributor Author

grubberr commented Sep 6, 2022

@sherifnada I have double checked pydentic PR(s) and Issue(s) about that problem with const:

pydantic/pydantic#4031
pydantic/pydantic#4152

I see that pydentic team thinks that old behaviour (without default) was incorrect and they just fixed old behaviour.
I don't see a way to change it (at least not hacking library)

@teallarson
Copy link
Contributor

teallarson commented Sep 6, 2022

Is my understanding correct that this should not change any existing frontend behavior and we'd continue reading the same keyword in the spec?

@grubberr @sherifnada If that is the case I believe this will not cause issues. The frontend types for connectors trust what the connector sends us and this appears to be solely an additive change. I tested it out locally in Storybook (our frontend component library) and the form is still able to at least render with the additional keyword in the spec.

I strongly recommend this be manually tested in the UI to ensure that all of the user interaction still works as expected.

This could be achieved by:

  1. changing a connector to use this format
  2. running OSS against that connector and trying it out in the UI

I have not done this as I'm only sure how to do step 1 (would like to know how to do step 2, if someone can point me in the right direction I can try it out).

Another conservative measure would be to add a test to the frontend code where we parse the specs to ensure that it handles a spec with this keyword as expected (which, if I understand correctly, we should just ignore?). Happy to help get that in place.

I agree, I'd really rather be safe than sorry in ensuring users can setup their connectors.

@sherifnada sherifnada removed their request for review September 15, 2022 23:18
@sherifnada
Copy link
Contributor

sherifnada commented Sep 15, 2022

@grubberr is there a way to override this behavior in Pydantic? If not, let's follow Teal's advice above:

  1. manually test in the UI
  2. create an issue for the frontend team asking them to add tests to validate this is safe to do

@grubberr
Copy link
Contributor Author

@sherifnada
Hello
I only can repeat my last message
#16172 (comment)

Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

@grubberr sounds fine with me, we'll need to follow the steps above to move this change forward

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CDK Connector Development Kit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants