Skip to content

Commit

Permalink
Merge pull request #8 from baikonur-oss/fix-failed-data-format
Browse files Browse the repository at this point in the history
Fix bad data output: JSON encode dictionaries
  • Loading branch information
prog893 authored Feb 11, 2020
2 parents acbc56e + d0c718e commit 0d91267
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lambda/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,18 @@ def bad_data_save(data: list, reason: str):
key += str(uuid.uuid4()) + ".gz"

logger.info(f"Saving failed records to S3: s3://{FAILED_LOG_S3_BUCKET}/{key}")
data = '\n'.join(str(f) for f in data)
data = '\n'.join(to_str(f) for f in data)
put_to_s3(key, FAILED_LOG_S3_BUCKET, data)

xray_recorder.end_subsegment()


def to_str(a):
if type(a) == dict:
return json.dumps(a)
return a


# noinspection PyUnusedLocal
def handler(event, context):
raw_records = event['Records']
Expand Down

0 comments on commit 0d91267

Please sign in to comment.