Skip to content

Commit

Permalink
resolve bug where 500 was raised when no rule violations occured
Browse files Browse the repository at this point in the history
Change-Id: I7aceebad0af549c8741e29f40e1792585244b25b
  • Loading branch information
psnelG committed Nov 7, 2023
1 parent d0a306c commit d0acb50
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions core/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,16 @@ def upload_rows(bq_legacy_client: BigQueryLegacyClient,
Returns:
* List of errors, if any
"""
result = bq_legacy_client.insert_rows_json(table_metadata.full_table_id,
rows)
# result is empty if no errors occurred
for row in result:
# Note:
# Failure here usually indicates a BigQuery log table schema issue
# We assume all rows will fail with the same error,
# so we only log one row to prevent polluting cloud logging
# and immediately return to stop processing data further
if 'errors' in row and len(row['errors']) > 0:
return [str(e) for e in row['errors']]
if len(rows) > 0:
result = bq_legacy_client.insert_rows_json(table_metadata.full_table_id,
rows)
# result is empty if no errors occurred
for row in result:
# Note:
# Failure here usually indicates a BigQuery log table schema issue
# We assume all rows will fail with the same error,
# so we only log one row to prevent polluting cloud logging
# and immediately return to stop processing data further
if 'errors' in row and len(row['errors']) > 0:
return [str(e) for e in row['errors']]
return []

0 comments on commit d0acb50

Please sign in to comment.