Use Seer AI to analyze root causes and generate solution plans for Sentry issues
Sentry CLI integrates with Seer AI to provide automated root cause analysis and solution planning for issues. The AI analyzes your error data, stack traces, and code context to identify what caused the issue and suggest how to fix it.
The issue explain command analyzes an issue and identifies the root cause:
sentry issue explain 123456789
The analysis provides:
Identified root causes
Reproduction steps
Relevant code locations
Human Output
$ sentry issue explain 123456789⠋ Analyzing issue...## Root Cause Analysis Complete### Cause #0: Null pointer exception in user authentication**Repository:** my-org/my-app**Reproduction steps:****Authentication flow when email is missing**The code attempts to access the email property without checkingif the user object exists:```pythondef authenticate_user(user): return user.email.lower() # user could be None
To create a plan, run: sentry issue plan 123456789
[ { "description": "Null pointer exception in user authentication", "relevant_repos": ["my-org/my-app"], "root_cause_reproduction": [ { "title": "Authentication flow when email is missing", "code_snippet_and_analysis": "The code attempts to access the email property without checking if the user object exists:\n\n```python\ndef authenticate_user(user):\n return user.email.lower() # user could be None\n```" } ] }]
The issue plan command generates a solution plan with implementation steps:
sentry issue plan 123456789 --cause 0
The plan command automatically runs root cause analysis if needed, so you don’t need to run explain first.
Human Output
JSON Output
$ sentry issue plan 123456789 --cause 0Creating plan for cause #0..."Null pointer exception in user authentication"⠋ Generating solution...## Solution**Summary:** Add null check before accessing user.email property### Steps to implement1. **Add user validation in authenticate_user** Update the authenticate_user function to check if user is None before accessing the email property. Return a default value or raise an appropriate exception.2. **Add unit tests for null user case** Create test cases to verify the function handles None users correctly without throwing unhandled exceptions.3. **Update caller code to handle exceptions** Ensure all callers of authenticate_user are prepared to handle the authentication failure cases appropriately.
$ sentry issue plan 123456789 --cause 0 --json
{ "run_id": "autofix-abc123", "status": "COMPLETED", "solution": { "one_line_summary": "Add null check before accessing user.email property", "steps": [ { "title": "Add user validation in authenticate_user", "description": "Update the authenticate_user function to check if user is None before accessing the email property. Return a default value or raise an appropriate exception." }, { "title": "Add unit tests for null user case", "description": "Create test cases to verify the function handles None users correctly without throwing unhandled exceptions." }, { "title": "Update caller code to handle exceptions", "description": "Ensure all callers of authenticate_user are prepared to handle the authentication failure cases appropriately." } ] }}
If multiple root causes are identified, you must specify which one to plan for:
# If you try without --cause when multiple exist:$ sentry issue plan 123456789Error: Multiple root causes found. Please specify one with --cause <id>: 0: Null pointer exception in user authentication... 1: Missing rate limiting on authentication endpoint...Example: sentry issue plan 123456789 --cause 0