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 Mailchimp: handle records with no no "activity" field in response #5024

Merged

Conversation

vovavovavovavova
Copy link
Contributor

What

Closes #4787

How

The email-activity web response usually contains the set of fields, including "activity" - main resource field. Using our data, we always receiving this field, it may be an empty array, but it always exist. In the issue we might have unexpected case that response does not contain this field, so it fails with an exception. Now those records are skipped, like it was on empty array - additional reason that the cursor field is located inside this field.
Since we cannot debug user data, assuming this can close the issue.
Some schemas were changed too.

Recommended reading order

  1. x.java
  2. y.python

Pre-merge Checklist

Expand the checklist which is relevant for this PR.

Connector checklist

  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • Secrets are annotated with airbyte_secret in the connector's spec
  • Credentials added to Github CI if needed and not already present. instructions for injecting secrets into CI.
  • Unit & integration tests added as appropriate (and are passing)
    • Community members: please provide proof of this succeeding locally e.g: screenshot or copy-paste acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • /test connector=connectors/<name> command as documented here is passing.
    • Community members can skip this, Airbyters will run this for you.
  • Code reviews completed
  • Documentation updated
    • README.md
    • docs/SUMMARY.md if it's a new connector
    • Created or updated reference docs in docs/integrations/<source or destination>/<name>.
    • Changelog in the appropriate page in docs/integrations/.... See changelog example
    • docs/integrations/README.md contains a reference to the new connector
    • Build status added to build page
  • Build is successful
  • Connector version bumped like described here
  • New Connector version released on Dockerhub by running the /publish command described here
  • No major blockers
  • PR merged into master branch
  • Follow up tickets have been created
  • Associated tickets have been closed & stakeholders notified

Connector Generator checklist

  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed.

@github-actions github-actions bot added the area/connectors Connector related issues label Jul 27, 2021
@vovavovavovavova
Copy link
Contributor Author

vovavovavovavova commented Jul 27, 2021

/test connector=connectors/source-mailchimp

🕑 connectors/source-mailchimp https://github.com/airbytehq/airbyte/actions/runs/1071407504
✅ connectors/source-mailchimp https://github.com/airbytehq/airbyte/actions/runs/1071407504

@vovavovavovavova vovavovavovavova changed the title cover if no "activity" field in response Source Mailchimp: handle records with no no "activity" field in response Jul 27, 2021
@@ -177,8 +177,9 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp
# -> [[{'campaign_id', 'list_id', 'list_is_active', 'email_id', 'email_address', '**activity[i]', '_links'}, ...]]
data = response_json[self.data_field]
for item in data:
for activity_record in item["activity"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

mb just

for activity_record in item.get("activity", []):

?

@vovavovavovavova
Copy link
Contributor Author

vovavovavovavova commented Jul 27, 2021

/test connector=connectors/source-mailchimp

🕑 connectors/source-mailchimp https://github.com/airbytehq/airbyte/actions/runs/1071488754
✅ connectors/source-mailchimp https://github.com/airbytehq/airbyte/actions/runs/1071488754

Comment on lines 181 to 185
for activity_record in item["activity"]:
new_record = {k: v for k, v in item.items() if k != "activity"}
for k, v in activity_record.items():
new_record[k] = v
yield new_record
Copy link
Contributor

@keu keu Jul 27, 2021

Choose a reason for hiding this comment

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

or somthing like this

Suggested change
for activity_record in item["activity"]:
new_record = {k: v for k, v in item.items() if k != "activity"}
for k, v in activity_record.items():
new_record[k] = v
yield new_record
for activity_item in item.pop("activity", []):
yield {**item, **activity_item}

Copy link
Contributor

@keu keu left a comment

Choose a reason for hiding this comment

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

see comment

@vovavovavovavova vovavovavovavova requested review from vitaliizazmic and removed request for htrueman, Zirochkaa and yevhenii-ldv July 27, 2021 14:21
@vovavovavovavova
Copy link
Contributor Author

vovavovavovavova commented Jul 27, 2021

/test connector=connectors/source-mailchimp

🕑 connectors/source-mailchimp https://github.com/airbytehq/airbyte/actions/runs/1071628590
✅ connectors/source-mailchimp https://github.com/airbytehq/airbyte/actions/runs/1071628590

@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Jul 28, 2021
@vovavovavovavova
Copy link
Contributor Author

vovavovavovavova commented Jul 28, 2021

/publish connector=connectors/source-mailchimp

🕑 connectors/source-mailchimp https://github.com/airbytehq/airbyte/actions/runs/1075209224
✅ connectors/source-mailchimp https://github.com/airbytehq/airbyte/actions/runs/1075209224

@vovavovavovavova vovavovavovavova merged commit 283731b into master Jul 28, 2021
@vovavovavovavova vovavovavovavova deleted the valdemar/#4787_possible_mailchimp_data_change branch July 28, 2021 14:27
@sherifnada
Copy link
Contributor

@vovavovavovavova please remember to add the 🎉 emoji to the PR title to make it visible for changelog writers

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MailChimp -> BigQuery: On sync fails with KeyError: 'activity'
4 participants