- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 4.5k
 
fix(workflow_engine): Finish dataSource => dataSources #102184
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
Conversation
…sources / dataSources
047c6d0    to
    a782c90      
    Compare
  
    
          Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@             Coverage Diff             @@
##           master   #102184      +/-   ##
===========================================
- Coverage   80.96%    80.90%   -0.06%     
===========================================
  Files        8747      8749       +2     
  Lines      389157    390152     +995     
  Branches    24729     24729              
===========================================
+ Hits       315082    315671     +589     
- Misses      73721     74127     +406     
  Partials      354       354               | 
    
| if "data_sources" in validated_data: | ||
| data_source = validated_data.pop("data_sources")[0] | ||
| 
               | 
          ||
| if data_source is not None: | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Accessing [0] on an empty data_sources list, allowed by ListField without min_length, causes an IndexError.
Severity: CRITICAL | Confidence: 0.95
🔍 Detailed Analysis
The data_sources field, defined as a serializers.ListField without a min_length constraint, allows an empty list [] to pass validation. When a client submits an empty list for data_sources, the code attempts to access validated_data.pop("data_sources")[0]. This operation on an empty list results in an IndexError: list index out of range, causing an unhandled exception. This occurs in the update() methods of UptimeDomainCheckFailureValidator, MetricIssueDetectorValidator, and MonitorIncidentDetectorValidator, as well as the create() method of MetricIssueDetectorValidator.
💡 Suggested Fix
Add min_length=1 to the data_sources ListField definitions in UptimeDomainCheckFailureValidator, MetricIssueDetectorValidator, and MonitorIncidentDetectorValidator. Alternatively, add a check for a non-empty list before accessing [0].
🤖 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/uptime/endpoints/validators.py#L469-L472
Potential issue: The `data_sources` field, defined as a `serializers.ListField` without
a `min_length` constraint, allows an empty list `[]` to pass validation. When a client
submits an empty list for `data_sources`, the code attempts to access
`validated_data.pop("data_sources")[0]`. This operation on an empty list results in an
`IndexError: list index out of range`, causing an unhandled exception. This occurs in
the `update()` methods of `UptimeDomainCheckFailureValidator`,
`MetricIssueDetectorValidator`, and `MonitorIncidentDetectorValidator`, as well as the
`create()` method of `MetricIssueDetectorValidator`.
Did we get this right? 👍 / 👎 to inform future reviews.
          Issues attributed to commits in this pull requestThis pull request was merged and Sentry observed the following issues:  | 
    
Description
This PR finishes the dataSource to dataSources transition on the API validator, removing
data_sourcefrom validators and updating tests.