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

☝🏼 Upgrade all connectors (0.2.0) so protocol allows future / unknown properties #2238

Merged
merged 8 commits into from
Mar 9, 2021

Conversation

ChristopheDuong
Copy link
Contributor

@ChristopheDuong ChristopheDuong commented Mar 1, 2021

What

This PR unblocks #2228 which needs to add new properties to the protocol.

However, the current connectors are throwing JSON validation errors if we try to evolve the protocol with new properties as they are currently unknown to previously released connectors.

How

Describe the solution

Connectors should accept new properties (in case we add new features in the future) and continue working while ignoring those new properties.

This PR isn't introducing new actual features, it is just making sure that after this being merged, every source connectors will be able to properly run even if the protocol is changed in the future

Pre-merge Checklist

  • Run integration tests for all source connectors
  • Publish Docker images for all source connectors
  • Provide migration script to force upgrade all source connectors

Recommended reading order

  1. airbyte-commons/src/main/java/io/airbyte/commons/json/Jsons.java
  2. airbyte-migration/src/main/java/io/airbyte/migrate/migrations/MigrationV0_17_0.java
  3. the rest

@ChristopheDuong ChristopheDuong added this to the 2021-03-05 milestone Mar 1, 2021
@ChristopheDuong ChristopheDuong self-assigned this Mar 1, 2021
@ChristopheDuong
Copy link
Contributor Author

I would need some initial approval and then I will start publishing new connectors along with migration script if this is the proper path we want to take.

private static final ObjectWriter OBJECT_WRITER = OBJECT_MAPPER.writer(new JsonPrettyPrinter());

private static ObjectMapper initMapper() {
final ObjectMapper result = new ObjectMapper();
result.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. if in an object has additionalProperties=false, does this override it? or it his just overriding default behavior?
  2. shouldn't be be changing the additionalProperties field in objects as well (or instead, depending on the answer to the first question)?

Copy link
Contributor

Choose a reason for hiding this comment

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

To @cgardens point. There are 2 parts to allowing unknown properties:

  1. Ensure our Json SerDe accepts it
  2. Ensure our Json Schema validation accepts it

The PR only address the first point.

@cgardens I don't think your first point matter since additionalProperties only makes sense once the model goes through validation.

Copy link
Contributor Author

@ChristopheDuong ChristopheDuong Mar 2, 2021

Choose a reason for hiding this comment

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

The additionalProperties fields seem to influence only the JSON Schema validation as explained by Michel (which results in modifications to generated files for pydantic only?)

The Jackson SerDe operations are only configured by the ObjectMapper feature configure call.

  • Anyway, I ran a manual test where I've tried building a docker image / artifact of a connector from this branch.
  • Then I tested with modifications to the protocol (on top of the Step 2: Add Namespace to Airbyte Protocol #2228 branch changes)
  • I verified that JSON validation in the connector works thanks to this PR. (Connectors with versions 0.1.X would fail)
  • So everything is able to run normally (even though the connector is not supposed to support namespace fields yet)

Copy link
Contributor

Choose a reason for hiding this comment

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

are you saying this change isn't necessary or that this change is what makes this possible? if you know what's going on here then i'm sure it's fine. i'm not fully understanding your last comment though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, these are the changes that make it possible

Copy link
Contributor

@michel-tricot michel-tricot left a comment

Choose a reason for hiding this comment

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

Once you've also addressed the validation and updated all the connectors that need it, I think the PR is good to go.

private static final ObjectWriter OBJECT_WRITER = OBJECT_MAPPER.writer(new JsonPrettyPrinter());

private static ObjectMapper initMapper() {
final ObjectMapper result = new ObjectMapper();
result.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

To @cgardens point. There are 2 parts to allowing unknown properties:

  1. Ensure our Json SerDe accepts it
  2. Ensure our Json Schema validation accepts it

The PR only address the first point.

@cgardens I don't think your first point matter since additionalProperties only makes sense once the model goes through validation.

@cgardens cgardens self-requested a review March 2, 2021 19:57
Copy link
Contributor

@cgardens cgardens left a comment

Choose a reason for hiding this comment

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

i think we don't need to copy the full definitions file. other than that looks good.

private static final ObjectWriter OBJECT_WRITER = OBJECT_MAPPER.writer(new JsonPrettyPrinter());

private static ObjectMapper initMapper() {
final ObjectMapper result = new ObjectMapper();
result.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

are you saying this change isn't necessary or that this change is what makes this possible? if you know what's going on here then i'm sure it's fine. i'm not fully understanding your last comment though.

@cgardens
Copy link
Contributor

cgardens commented Mar 2, 2021

I understand why you want to write a migration. I didn't know we were going to automatically force upgrade connectors. I like the idea though and it seems like a good choice that saves customers headache in this case.

Copy link
Contributor

@michel-tricot michel-tricot left a comment

Choose a reason for hiding this comment

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

LGTM % charles comments

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/source-appstore-singer

🕑 connectors/source-appstore-singer https://github.com/airbytehq/airbyte/actions/runs/617464383
✅ connectors/source-appstore-singer https://github.com/airbytehq/airbyte/actions/runs/617464383

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/source-braintree-singer

🕑 connectors/source-braintree-singer https://github.com/airbytehq/airbyte/actions/runs/617492893
✅ connectors/source-braintree-singer https://github.com/airbytehq/airbyte/actions/runs/617492893

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/destination-postgres

🕑 connectors/destination-postgres https://github.com/airbytehq/airbyte/actions/runs/617543998
✅ connectors/destination-postgres https://github.com/airbytehq/airbyte/actions/runs/617543998

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/source-drift

🕑 connectors/source-drift https://github.com/airbytehq/airbyte/actions/runs/617565339
❌ connectors/source-drift https://github.com/airbytehq/airbyte/actions/runs/617565339
🕑 connectors/source-drift https://github.com/airbytehq/airbyte/actions/runs/617565339
❌ connectors/source-drift https://github.com/airbytehq/airbyte/actions/runs/617565339

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/source-exchangeratesapi-singer

🕑 connectors/source-exchangeratesapi-singer https://github.com/airbytehq/airbyte/actions/runs/617565291
✅ connectors/source-exchangeratesapi-singer https://github.com/airbytehq/airbyte/actions/runs/617565291

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/source-facebook-marketing

🕑 connectors/source-facebook-marketing https://github.com/airbytehq/airbyte/actions/runs/617565416
✅ connectors/source-facebook-marketing https://github.com/airbytehq/airbyte/actions/runs/617565416

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/source-file

🕑 connectors/source-file https://github.com/airbytehq/airbyte/actions/runs/617565426
✅ connectors/source-file https://github.com/airbytehq/airbyte/actions/runs/617565426

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/source-freshdesk

🕑 connectors/source-freshdesk https://github.com/airbytehq/airbyte/actions/runs/617565568
✅ connectors/source-freshdesk https://github.com/airbytehq/airbyte/actions/runs/617565568

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/source-github-singer

🕑 connectors/source-github-singer https://github.com/airbytehq/airbyte/actions/runs/617565610
✅ connectors/source-github-singer https://github.com/airbytehq/airbyte/actions/runs/617565610

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/source-google-adwords-singer

🕑 connectors/source-google-adwords-singer https://github.com/airbytehq/airbyte/actions/runs/617565743
❌ connectors/source-google-adwords-singer https://github.com/airbytehq/airbyte/actions/runs/617565743

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/destination-csv

🕑 connectors/destination-csv https://github.com/airbytehq/airbyte/actions/runs/617587254
✅ connectors/destination-csv https://github.com/airbytehq/airbyte/actions/runs/617587254

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/destination-jdbc

🕑 connectors/destination-jdbc https://github.com/airbytehq/airbyte/actions/runs/617587285
✅ connectors/destination-jdbc https://github.com/airbytehq/airbyte/actions/runs/617587285

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/destination-local-json

🕑 connectors/destination-local-json https://github.com/airbytehq/airbyte/actions/runs/617587305
✅ connectors/destination-local-json https://github.com/airbytehq/airbyte/actions/runs/617587305

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/destination-meilisearch

🕑 connectors/destination-meilisearch https://github.com/airbytehq/airbyte/actions/runs/617587577
✅ connectors/destination-meilisearch https://github.com/airbytehq/airbyte/actions/runs/617587577

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/destination-redshift

🕑 connectors/destination-redshift https://github.com/airbytehq/airbyte/actions/runs/617587466
✅ connectors/destination-redshift https://github.com/airbytehq/airbyte/actions/runs/617587466

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/publish connector=connectors/destination-snowflake

🕑 connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/617587472
✅ connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/617587472

@ChristopheDuong
Copy link
Contributor Author

ChristopheDuong commented Mar 3, 2021

/test connector=source-drift

🕑 source-drift https://github.com/airbytehq/airbyte/actions/runs/617766492
❌ source-drift https://github.com/airbytehq/airbyte/actions/runs/617766492

@cgardens cgardens assigned cgardens and unassigned cgardens Mar 8, 2021
@ChristopheDuong ChristopheDuong merged commit 070575f into master Mar 9, 2021
@ChristopheDuong ChristopheDuong deleted the chris/protocol-with-unknown-properties branch March 9, 2021 12:36
@ChristopheDuong ChristopheDuong changed the title Protocol allows future / unknown properties ☝🏼 Upgrade all connectors so protocol allows future / unknown properties Mar 9, 2021
@ChristopheDuong ChristopheDuong changed the title ☝🏼 Upgrade all connectors so protocol allows future / unknown properties ☝🏼 Upgrade all connectors (0.2.0) so protocol allows future / unknown properties Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment