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-google-analytics-data-api] fix issue if metrics or dimensions api response does not have name field #30506

Merged

Conversation

brianjlai
Copy link
Contributor

What

Fixes OC issue https://github.com/airbytehq/oncall/issues/2973

How

The previous release didn't run into this issue because we took whatever value either a string or None and stored it into the list or mapping. However, once we started performing the replace(), it revealed that the API response might have metrics or dimensions that do not have a name field. Given its a P0 at midnight, I wanted to try to retain the prior working behavior as close as possible which would persist Nones into the list. I'm okay if we switch this to only put names if they exist as well.

Recommended reading order

  1. x.java
  2. y.python

🚨 User Impact 🚨

none

@octavia-squidington-iii octavia-squidington-iii added area/connectors Connector related issues area/documentation Improvements or additions to documentation labels Sep 17, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Sep 17, 2023

Before Merging a Connector Pull Request

Wow! What a great pull request you have here! 🎉

To merge this PR, ensure the following has been done/considered for each connector added or updated:

  • PR name follows PR naming conventions
  • Breaking changes are considered. If a Breaking Change is being introduced, ensure an Airbyte engineer has created a Breaking Change Plan.
  • Connector version has been incremented in the Dockerfile and metadata.yaml according to our Semantic Versioning for Connectors guidelines
  • You've updated the connector's metadata.yaml file any other relevant changes, including a breakingChanges entry for major version bumps. See metadata.yaml docs
  • Secrets in the connector's spec are annotated with airbyte_secret
  • All documentation files are up to date. (README.md, bootstrap.md, docs.md, etc...)
  • Changelog updated in docs/integrations/<source or destination>/<name>.md with an entry for the new version. See changelog example
  • Migration guide updated in docs/integrations/<source or destination>/<name>-migrations.md with an entry for the new version, if the version is a breaking change. See migration guide example
  • If set, you've ensured the icon is present in the platform-internal repo. (Docs)

If the checklist is complete, but the CI check is failing,

  1. Check for hidden checklists in your PR description

  2. Toggle the github label checklist-action-run on/off to re-run the checklist CI.

@brianjlai brianjlai changed the title fix issue if metrics or dimensions api response does not have name field 🐛 [source-google-analytics-data-api] fix issue if metrics or dimensions api response does not have name field Sep 17, 2023
metrics_type_map = {h.get("name").replace(":", "_"): h.get("type") for h in r.get("metricHeaders", [{}])}
dimensions = [h.get("name").replace(":", "_") if "name" in h else None for h in r.get("dimensionHeaders", [{}])]
metrics = [h.get("name").replace(":", "_") if "name" in h else None for h in r.get("metricHeaders", [{}])]
metrics_type_map = {h.get("name").replace(":", "_"): h.get("type") for h in r.get("metricHeaders", [{}]) if "name" in h}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the old behavior would actually end up with a dictionary that overwrites the None key for any metrics without a name. To me this feels a bit nonsensical so I opted to just skip over metrics missing the name.

As mentioned in the description, I would also be okay if we did the same for the other statements. It's much cleaner, but I'm not sure if there were downstream affects if we deviated from what we considered the earlier working behavior.

@github-actions
Copy link
Contributor

source-google-analytics-data-api test report (commit f3fd105243) - ✅

⏲️ Total pipeline duration: 33mn05s

Step Result
Connector package install
Build source-google-analytics-data-api docker image for platform linux/x86_64
Unit tests
Acceptance tests
Code format checks
Validate airbyte-integrations/connectors/source-google-analytics-data-api/metadata.yaml
Connector version semver check
Connector version increment check
QA checks

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-google-analytics-data-api test

@github-actions
Copy link
Contributor

source-google-analytics-data-api test report (commit 6fad5561b0) - ✅

⏲️ Total pipeline duration: 32mn47s

Step Result
Connector package install
Build source-google-analytics-data-api docker image for platform linux/x86_64
Unit tests
Acceptance tests
Code format checks
Validate airbyte-integrations/connectors/source-google-analytics-data-api/metadata.yaml
Connector version semver check
Connector version increment check
QA checks

🔗 View the logs here

☁️ View runs for commit in Dagger Cloud

Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.
You can run the same pipeline locally on this branch with the airbyte-ci tool with the following command

airbyte-ci connectors --name=source-google-analytics-data-api test

@brianjlai brianjlai merged commit 90375ee into master Sep 17, 2023
25 checks passed
@brianjlai brianjlai deleted the brian/google_analytics_data_api_none_dimension_response branch September 17, 2023 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation connectors/source/google-analytics-data-api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants