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

Source TikTok Marketing : Access token is null #14299 #14461

Merged
merged 9 commits into from
Jul 13, 2022

Conversation

alexandr-shegeda
Copy link
Contributor

@alexandr-shegeda alexandr-shegeda commented Jul 6, 2022

What

After recent changes introduced in this PR logic related to path recalculation for JSON nodes we faced an issue for connectors that contain oneOf elements that have the same field names. So, for described case getSortedSecretPaths() returned duplicates, which lead to incorrect postprocessing during secret replacement.

How

Made getSortedSecretPaths() return a unique values.

Recommended reading order

  1. SecretsHelpers.java

🚨 User Impact 🚨

Without these changes, users are not able to configure a proper connection using multiple auth options on spec.

Pre-merge Checklist

Updating a connector

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub and connector version bumped by running the /publish command described here

Tests

Unit

Before fix:
Screenshot 2022-07-13 at 12 58 17

Screenshot 2022-07-13 at 12 57 37

After fix:

image

Integration

Put your integration tests output here.

Acceptance

Put your acceptance tests output here.

@alexandr-shegeda alexandr-shegeda linked an issue Jul 6, 2022 that may be closed by this pull request
@alexandr-shegeda alexandr-shegeda temporarily deployed to more-secrets July 6, 2022 18:02 Inactive
@grishick
Copy link
Contributor

grishick commented Jul 6, 2022

because this change affects many connectors, please test that it does not break any GA and Beta connectors and also verify that it does not break jobs after a user upgrades to a platform version

@@ -178,6 +178,7 @@ public static List<String> getSortedSecretPaths(final JsonNode spec) {
.anyMatch(field -> field.getKey().equals(JsonSecretsProcessor.AIRBYTE_SECRET_FIELD)))
.stream()
.map(JsonPaths::mapJsonSchemaPathToJsonPath)
.distinct()
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a unit test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added unit tests. will attach screenshots with failed tests without this change

Copy link
Contributor

Choose a reason for hiding this comment

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

can you add in the javadoc comment that it will not return duplicates?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added javadoc

@kimerinn
Copy link
Contributor

kimerinn commented Jul 8, 2022

image

TikTok works well

@kimerinn
Copy link
Contributor

kimerinn commented Jul 8, 2022

BigQuery also

image

@kimerinn
Copy link
Contributor

kimerinn commented Jul 8, 2022

GitHub
image

@kimerinn kimerinn temporarily deployed to more-secrets July 8, 2022 09:52 Inactive
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.

We need tests here that show the problem and then how this fixes it.

@alexandr-shegeda alexandr-shegeda temporarily deployed to more-secrets July 13, 2022 10:08 Inactive
@alexandr-shegeda
Copy link
Contributor Author

We need tests here that show the problem and then how this fixes it.

hi @cgardens, I have added unit tests for the described case, and also updated the description with failed unit tests without the fix.

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.

thanks! the test is great.

can you point to what line of code causes things to work in an unexpected way when there are duplicates? this is still not intuitive to me, and i want to understand where the brittleness is coming from.

@@ -178,6 +178,7 @@ public static List<String> getSortedSecretPaths(final JsonNode spec) {
.anyMatch(field -> field.getKey().equals(JsonSecretsProcessor.AIRBYTE_SECRET_FIELD)))
.stream()
.map(JsonPaths::mapJsonSchemaPathToJsonPath)
.distinct()
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add in the javadoc comment that it will not return duplicates?

@alexandr-shegeda
Copy link
Contributor Author

thanks! the test is great.

can you point to what line of code causes things to work in an unexpected way when there are duplicates? this is still not intuitive to me, and i want to understand where the brittleness is coming from.

@cgardens in case SecretsHelpers#getSortedSecretPaths return duplicate path
then inside of SecretsHelpers#internalSplitAndUpdateConfig we will replace incoming config value with the secret, and then after the second run of method JsonPaths.replaceAt()
it will not find a value of the original field, because it was replaced with {"_secret" : "..."}, so we will just erase the secret value as it showed on this screenshot Screenshot 2022-07-13 at 12 57 37

@benmoriceau benmoriceau temporarily deployed to more-secrets July 13, 2022 19:16 Inactive
Copy link
Contributor

@supertopher supertopher left a comment

Choose a reason for hiding this comment

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

Based on local testing and my understanding of the problem space this looks good to go.

Tik Tok access token are broken so we hope to see a more different error here.

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.

Thank, @alexandr-shegeda ! That explanation makes sense to me too. I think we are good to go on this.

@benmoriceau
Copy link
Contributor

benmoriceau commented Jul 13, 2022

thanks! the test is great.

can you point to what line of code causes things to work in an unexpected way when there are duplicates? this is still not intuitive to me, and i want to understand where the brittleness is coming from.

@cgardens The issue is because this duplicated are secrets. Here is what happens:

  • We have 2 paths for the secret that are deplicated (because they are in a oneOf)
  • For each path we will try to sanitize the config in order to hide the secret and store in the secret manager
  • The first one works well, store the secret in the secret store and replace the value by a coordiante
  • The second on can read the secret value because it has been replace by a coordinate but doesn't error out and replace the first coordinate by a new coordinate.
  • Then when we try to retrieve the secret value, it is invalid.
    Does it makes sense?

Edit: Sorry I didn't saw that the explaination was post already

Copy link
Contributor

@supertopher supertopher left a comment

Choose a reason for hiding this comment

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

triple approve?

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.

Source TikTok Marketing : Access token is null
8 participants