Production Exception & Stack Trace Root-Cause Analyzer
Analyze production stack traces, error logs, and surrounding code using hypothesis-driven debugging.
Interactive Prompt Playground
{{STACK_TRACE}}{{SOURCE_CODE}}{{RUNTIME}}{{CONTEXT}}You are a Principal Reliability Engineer and Debugging Specialist investigating a production outage.
Error Message / Stack Trace:
```
java.lang.NullPointerException: Cannot invoke "com.example.User.getOrganizationId()" because "user" is null
at com.example.service.BillingService.calculateDiscount(BillingService.java:84)
at com.example.service.BillingService.generateInvoice(BillingService.java:42)
at com.example.controller.InvoiceController.create(InvoiceController.java:29)
```
Relevant Source Code:
```
public BigDecimal calculateDiscount(String userId, BigDecimal baseAmount) {
User user = userRepository.findByExternalId(userId);
// Line 84 below:
String orgId = user.getOrganizationId();
Organization org = organizationRepository.findById(orgId).orElseThrow();
return baseAmount.multiply(org.getDiscountRate());
}
```
System Context & Environment:
- Platform / Runtime: Java 21 / Spring Boot 3.2
- Recent Deployments / Triggers: Occurs intermittently when new guest users checkout without an external ID sync
Perform a methodical root-cause investigation:
1. **Error Classification & Mechanics**:
- What exact line and operation triggered the failure?
- What state or variable condition caused this specific exception?
2. **Hypothesis Formulation & Evidence**:
- Formulate 2-3 prioritized hypotheses for why this state occurred (e.g. race condition, null dereference, unhandled network timeout, bad payload).
- Detail the exact evidence from the stack trace supporting or ruling out each hypothesis.
3. **Defensive Fix & Prevention**:
- Provide the immediate code patch to handle this safely.
- Suggest regression unit/integration tests to ensure this never recurs.
- Recommend observability improvements (metrics/structured log fields) for early detection.How to Use This Prompt
- Paste the exact stack trace and log output from your monitoring tool (Datadog, Sentry, CloudWatch).
- Paste the surrounding method source code.
- Get a clear diagnosis and verified code patch.
Engineering Tips & Best Practices
- Include 2-3 lines of preceding application logs to give the model context on the incoming request payload.
What This Prompt Inspects
Key failure modes, design principles, and quality standards evaluated during execution.
Root Cause vs Symptom
Pinpoints why the invalid state existed rather than just adding a surface null check.
Defensive Coding
Implements Optional / result pattern handling for missing entity lookups.
Regression Test Plan
Provides automated test cases reproducing the exact failure scenario.
SprintKit Workflow Integrations
Complementary interactive tools and workflows across SprintKit to accelerate your engineering process.
Related Prompts
Explore related developer prompts in this workflow domain.
Database Deadlock & Concurrency Race Condition Investigator
Diagnose Postgres/MySQL transaction deadlocks, lock contention, and concurrent update race conditions.
API Performance Regression & N+1 Query Debugger
Identify slow database queries, serialization bottlenecks, and memory churn in sluggish API endpoints.
Unit Test Suite Generator with Edge Cases
Generate comprehensive, mutation-tested unit tests with AAA pattern, boundary cases, and proper mock boundaries.