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

TDL-22606 fix none replication_value records sync #122

Merged
merged 5 commits into from Apr 6, 2023

Conversation

RushiT0122
Copy link
Contributor

@RushiT0122 RushiT0122 commented Apr 4, 2023

Description of change

Fix TypeError observed while syncing accounts records (TDL-22606)

There were two scenarios which could cause TypeError which we fixed,

  • None replication_value records in parent streams
  • L#628 returns none for Account streams because we are trying to access non-existent key in a record.

Also, refactored code to avoid duplication code and have generic implementation.

Manual QA steps

  • Simulated none replication value records and tested implementation on local dev env.
  • Verified Account stream sync doesn't break if there are more records than record_limit value.
  • Verified unittests and integration tests pass on local env.

Risks

Rollback steps

  • revert this branch

@RushiT0122 RushiT0122 requested review from dsprayberry and kethan1122 and removed request for dsprayberry and kethan1122 April 4, 2023 13:17
@RushiT0122 RushiT0122 changed the title fix none replication_value recor sync fix none replication_value records sync Apr 4, 2023
tap_pendo/streams.py Outdated Show resolved Hide resolved
tap_pendo/streams.py Outdated Show resolved Hide resolved
tap_pendo/streams.py Outdated Show resolved Hide resolved
@dsprayberry dsprayberry changed the title fix none replication_value records sync TDL-22606 fix none replication_value records sync Apr 5, 2023
tap_pendo/streams.py Show resolved Hide resolved
if isinstance(self, Accounts):
return record['metadata']['auto']['lastupdated']

decamalized_replication_key = humps.decamelize(self.replication_key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo in "decamalized" should be "decamelized..."

return record['metadata']['auto']['lastupdated']

decamalized_replication_key = humps.decamelize(self.replication_key)
return record.get(decamalized_replication_key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo in "decamalized" should be "decamelized..."

@@ -549,20 +550,41 @@ def set_request_body_filters(self, body, start_time, records=None):

return body

def get_replication_value(self, record):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should rename this to be a little more concise, eg get_replication_key_value

@@ -549,20 +550,41 @@ def set_request_body_filters(self, body, start_time, records=None):

return body

def get_replication_value(self, record):
"""Return the replication value of """
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like an incomplete thought; was there more to this docstring?

@@ -149,6 +149,7 @@ class Stream():
def __init__(self, config=None):
self.config = config
self.record_limit = self.get_default_record_limit()
self.none_replication_value_records = []
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can rename this to make it slightly clearer; something like empty_replication_key_records' or empty_rk_records' if we want to shorten it

decamalized_replication_key = humps.decamelize(self.replication_key)
return record.get(decamalized_replication_key)

def remove_none_replication_value_records(self, records):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should rename this to align with the change requested above for line 152. something like remove_empty_rk_records

tap_pendo/streams.py Show resolved Hide resolved
@RushiT0122
Copy link
Contributor Author

RushiT0122 commented Apr 5, 2023

@dsprayberry fixed the comments, please re-review.

@RushiT0122 RushiT0122 force-pushed the patch-accounts-replication-key-issue branch from 92d4e4f to 7a62090 Compare April 6, 2023 07:14
@RushiT0122 RushiT0122 merged commit 4931dfb into master Apr 6, 2023
1 check passed
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.

None yet

4 participants