Skip to content

Commit b9fd89c

Browse files
RajivTSmeta-codesync[bot]
authored andcommitted
Handle empty Scuba table in merge resolution blame checker
Summary: When the mononoke_merge_resolution_alerts Scuba table has no data (e.g. no alerts have been written yet), query_sql_as_dict raises ValueError because the SQLQueryResult is not valid. This caused noisy ERROR logs in the Chronos job output. Fix: Catch ValueError in _query_scuba and return an empty list, since an empty result is a valid outcome. Log at DEBUG level instead of letting the exception propagate to callers that log at ERROR. Reviewed By: YousefSalama Differential Revision: D100162450 fbshipit-source-id: 908845cbff3446ab790f292a10ed85c1c8e0b2db
1 parent a837ac9 commit b9fd89c

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

eden/mononoke/scripts/merge_resolution_blame_checker.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,23 @@ def _check_diffs_reverted(diff_ids: list[str]) -> list[str]:
144144
async def _query_scuba(
145145
sql: str, table: str, user_name: str, user_id: int
146146
) -> list[dict[str, ResultType]]:
147-
"""Execute a Scuba SQL query and return results."""
148-
return await query_sql_as_dict(
149-
table=table,
150-
sql=sql,
151-
source=SCUBA_SOURCE,
152-
user_name=user_name,
153-
user_id=user_id,
154-
)
147+
"""Execute a Scuba SQL query and return results.
148+
149+
Returns an empty list when the query returns no rows (e.g. empty table).
150+
query_sql_as_dict raises ValueError when the underlying SQLQueryResult
151+
is not valid, which happens when the Scuba table has no matching data.
152+
"""
153+
try:
154+
return await query_sql_as_dict(
155+
table=table,
156+
sql=sql,
157+
source=SCUBA_SOURCE,
158+
user_name=user_name,
159+
user_id=user_id,
160+
)
161+
except ValueError:
162+
logger.debug("Scuba query returned no results for table %s", table)
163+
return []
155164

156165

157166
async def check_merge_resolution_blames(

0 commit comments

Comments
 (0)