Skip to content

Conversation

@jasonyuezhang
Copy link
Owner

@propel-test-bot
Copy link

Include issue event-volume time series in get_issue_details response

Adds a small helper (_get_issue_event_timeseries) that fetches bucketed event counts for a specific issue via the /events-stats/ endpoint (dataset issuePlatform). The response is wired into get_issue_details, so callers now receive a new event_timeseries dict alongside the existing issue, event, and tag metadata. Unit tests extended to validate shape of the returned structure.

Key Changes

• Created helper src/sentry/seer/explorer/tools.py::_get_issue_event_timeseries to call /organizations/{slug}/events-stats/ with query issue:{short_id} and return {"count()": {"data": [...]}}
• Invoked helper inside get_issue_details; output exposed as new key event_timeseries in returned payload
• Refactored project-lookup logic: moved org_project_ids query above try/except to avoid duplicate ORM call
• Added extensive assertions in tests/sentry/seer/explorer/test_tools.py to ensure event_timeseries schema validity

Affected Areas

src/sentry/seer/explorer/tools.py (issue details logic, new endpoint call)
tests/sentry/seer/explorer/test_tools.py (unit tests)

This summary was automatically generated by @propel-code-bot

path=f"/organizations/{organization.slug}/events-stats/",
params=params,
)
if resp.status_code != 200 or not (resp.data or {}).get("data"):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[BestPractice]

The error condition check not (resp.data or {}).get("data") can fail if resp.data is not a dictionary. If the API returns a string, list, or None, calling .get() will raise an AttributeError, causing the function to crash instead of gracefully handling the error.

Suggested change
if resp.status_code != 200 or not (resp.data or {}).get("data"):
if resp.status_code != 200 or not isinstance(resp.data, dict) or not resp.data.get("data"):

Committable suggestion

Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Context for Agents
[**BestPractice**]

The error condition check `not (resp.data or {}).get("data")` can fail if `resp.data` is not a dictionary. If the API returns a string, list, or None, calling `.get()` will raise an AttributeError, causing the function to crash instead of gracefully handling the error.

```suggestion
if resp.status_code != 200 or not isinstance(resp.data, dict) or not resp.data.get("data"):
```

⚡ **Committable suggestion**

Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

File: src/sentry/seer/explorer/tools.py
Line: 356

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants