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

add read only fields to memory, clean record #23

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
bump logic to extract read-only fields
keyn4 committed Sep 12, 2024
commit 1b96ab8c1aaa5ea014268b11b7fe24cad14d0a36
11 changes: 7 additions & 4 deletions target_salesforce_v3/sinks.py
Original file line number Diff line number Diff line change
@@ -1012,13 +1012,16 @@ def upsert_record(self, record, context):
return id, True, state_updates
except Exception as e:
if "INVALID_FIELD_FOR_INSERT_UPDATE" in str(e):
fields = json.loads(str(e))[0]['fields']
try:
fields = json.loads(str(e))[0]['fields']
except:
raise Exception(f"Attempted to write read-only fields. Unable to extract read-only fields to retry request: {str(e)}")

self.logger.warning(f"Attempted to write read-only fields: {fields}. Removing them and retrying.")
# append read-only field to a list
if not self._target.read_only_fields.get(self.stream_name):
self._target.read_only_fields[self.stream_name] = fields
else:
self._target.read_only_fields[self.stream_name].extend(fields)
self._target.read_only_fields[self.stream_name] = []
self._target.read_only_fields[self.stream_name].extend(fields)
# remove read-only fields from record
for f in fields:
record.pop(f, None)