Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #104921 +/- ##
===========================================
+ Coverage 80.26% 80.43% +0.17%
===========================================
Files 9396 9395 -1
Lines 403570 403235 -335
Branches 25903 25869 -34
===========================================
+ Hits 323911 324360 +449
+ Misses 79224 78440 -784
Partials 435 435 |
| stats_period, start, end, default_stats_period="24h" | ||
| ) | ||
|
|
||
| organization = Organization.objects.get(id=organization_id) |
There was a problem hiding this comment.
Bug: The execute_trace_table_query function does not handle the Organization.DoesNotExist exception, which will cause a crash if an invalid organization ID is passed.
Severity: CRITICAL | Confidence: High
🔍 Detailed Analysis
The function execute_trace_table_query calls Organization.objects.get(id=organization_id) without handling the Organization.DoesNotExist exception that can be raised if an invalid organization_id is provided. This is inconsistent with numerous other similar functions within the same file, such as execute_table_query and execute_timeseries_query, which wrap this lookup in a try-except block and return None gracefully. The absence of this exception handling will cause an unhandled exception, leading to a crash in the server process handling the RPC call.
💡 Suggested Fix
Wrap the Organization.objects.get(id=organization_id) call in execute_trace_table_query with a try-except Organization.DoesNotExist block. In the except block, log a warning and return None, mirroring the error handling pattern used by other query functions in the same file.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/sentry/seer/explorer/tools.py#L314
Potential issue: The function `execute_trace_table_query` calls
`Organization.objects.get(id=organization_id)` without handling the
`Organization.DoesNotExist` exception that can be raised if an invalid `organization_id`
is provided. This is inconsistent with numerous other similar functions within the same
file, such as `execute_table_query` and `execute_timeseries_query`, which wrap this
lookup in a `try-except` block and return `None` gracefully. The absence of this
exception handling will cause an unhandled exception, leading to a crash in the server
process handling the RPC call.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 7539742
rpc for our agents to query trace samples (only span samples are supported atm). Works similar to the /explore/traces/ page.
closes AIML-2072: trace table rpc