Issue Report Generator
Overview
Generate comprehensive, developer-friendly issue reports from failing tests. Analyze test failures, identify affected code, infer root causes when possible, and produce structured Markdown reports ready for issue tracking systems.
Report Generation Workflow
Step 1: Analyze the Failing Test
Understand what the test is checking and why it fails:
-
Identify the test:
- Test file path
- Test class/function name
- Test method name
-
Understand test intent:
- What functionality is being tested?
- What is the expected behavior?
- What assertions are being made?
-
Analyze the failure:
- Exception type (if any)
- Assertion failure details
- Expected vs. actual values
- Error messages
- Stack trace
-
Extract key information:
- Failure type (exception, assertion, timeout, etc.)
- Failure location (file, line number)
- Failure context (method calls, parameters)
Step 2: Identify Affected Code Components
Locate the code related to the failure:
-
From stack trace:
- Extract file paths
- Extract class/method names
- Extract line numbers
- Identify the failure point
-
From test code:
- Find the method/class being tested
- Identify dependencies
- Locate related components
-
Code analysis:
- Read the failing code section
- Understand the logic
- Identify potential issues
-
Record locations:
- Primary affected file(s)
- Specific methods/functions
- Line numbers or ranges
Step 3: Infer Root Cause
Determine why the failure occurs (when possible):
-
For exceptions:
- Which variable/object caused it?
- Why is it null/invalid?
- Where should it be initialized?
- What condition triggers the exception?
-
For assertion failures:
- Why does actual differ from expected?
- What code produces the wrong value?
- What condition causes the mismatch?
- Is there a logic error?
-
For timeouts:
- What operation is slow?
- Is there an infinite loop?
- Is there inefficient algorithm?
- Are there blocking operations?
-
For integration failures:
- What external system failed?
- What's the error from that system?
- Is it configuration?
- Is it connection?
-
State uncertainty:
- If root cause is unclear, say so
- Use "suspected," "likely," "appears to be"
- Suggest areas for investigation
Step 4: Generate Report Structure
Create the issue report with required sections:
-
Title:
- Format:
[Exception/Issue] in [Component].[Method] - Or:
[Feature] returns incorrect [result] - Keep it concise (50-80 characters)
- Make it descriptive
- Format:
-
Description:
- Brief summary of the issue
- Context about when it occurs
- Impact on functionality
-
Steps to Reproduce:
- Test command to run
- Or code snippet to execute
- Minimal reproduction steps
-
Expected Behavior:
- What should happen
- Based on test assertions
- Based on documentation
-
Actual Behavior:
- What actually happens
- Include error messages
- Include stack traces
- Include assertion failures
-
Affected Code:
- File paths
- Class/method names
- Line numbers
- Code snippets if helpful
-
Analysis (optional):
- Suspected root cause
- Why it happens
- Suggested fix (if clear)
-
Additional Context:
- Test details
- Environment info
- Related issues
- Labels/severity
Step 5: Format and Finalize
Produce the final Markdown report:
-
Use proper Markdown:
- Headers for sections
- Code blocks for code/errors
- Lists for steps
- Bold for emphasis
-
Be precise:
- Use exact error messages
- Include full stack traces
- Reference specific locations
- Use technical terminology
-
Be clear:
- Developer-friendly language
- Avoid vague descriptions
- State facts, not opinions
- Indicate uncertainty
-
Be actionable:
- Provide reproduction steps
- Identify affected code
- Suggest investigation areas
- Make it easy to fix
Report Templates
For detailed templates and patterns, see report_patterns.md.
Quick Template Selection
| Failure Type | Template | Key Focus |
|---|---|---|
| Exception | Exception-Based Bug | Exception type, location, null/invalid variable |
| Assertion failure | Assertion Failure Bug | Expected vs. actual, wrong value source |
| Timeout | Performance/Timeout Bug | Slow operation, bottleneck |
| Integration error | Integration Failure Bug | External system, error message, config |
| Regression | Regression Bug | Breaking commit, what changed |
Examples
Example 1: NullPointerException
Input:
- Test:
UserServiceTest.testAuthenticateNonExistentUser - Error:
NullPointerException at UserService.java:45 - Stack trace provided
Generated Report:
# NullPointerException in UserService.authenticate() when user not found
## Description
A `NullPointerException` is thrown in `UserService.authenticate()` when attempting to authenticate a user that doesn't exist in the database. This causes the authentication endpoint to return a 500 error instead of properly handling the missing user case.
## Steps to Reproduce
1. Run test: `mvn test -Dtest=UserServiceTest#testAuthenticateNonExistentUser`
2. Or call: `userService.authenticate("nonexistent@example.com", "password")`
## Expected Behavior
The method should return an authentication failure result (e.g., `AuthResult.FAILED`) or throw a specific `UserNotFoundException`, not a `NullPointerException`.
## Actual Behavior
java.lang.NullPointerException at com.example.UserService.authenticate(UserService.java:45) at com.example.AuthController.login(AuthController.java:23) at com.example.UserServiceTest.testAuthenticateNonExistentUser(UserServiceTest.java:67)
## Affected Code
- **File:** `src/main/java/com/example/UserService.java`
- **Method:** `UserService.authenticate`
- **Line:** 45
**Code at line 45:**
```java
String hashedPassword = user.getPassword(); // user is null here
Analysis
The exception occurs because the user object is null when the user lookup fails (line 42). The code attempts to call user.getPassword() without checking if the user exists.
Suspected cause: Missing null check after user lookup.
Test Details
- Test file:
src/test/java/com/example/UserServiceTest.java - Test method:
testAuthenticateNonExistentUser
### Example 2: Assertion Failure
**Input:**
- Test: `CalculatorTest.testDivision`
- Error: `AssertionError: expected 2.5 but got 2.0`
**Generated Report:**
```markdown
# Calculator.divide() returns integer instead of decimal result
## Description
The `Calculator.divide()` method returns `2.0` instead of the expected `2.5` when dividing 5 by 2. This indicates the method is performing integer division instead of floating-point division.
## Steps to Reproduce
1. Run test: `pytest tests/test_calculator.py::CalculatorTest::test_division`
2. Or execute:
```python
calc = Calculator()
result = calc.divide(5, 2)
# Returns 2.0, expected 2.5
Expected Behavior
assert calc.divide(5, 2) == 2.5
Actual Behavior
AssertionError: assert 2.0 == 2.5
Expected: 2.5
Actual: 2.0
Affected Code
- File:
src/calculator.py - Method:
Calculator.divide - Lines: 15-16
Current implementation:
def divide(self, a, b):
return a / b # Using integer division
Analysis
The method performs integer division when both operands are integers. In Python 2 or when using // operator, this truncates the decimal part.
Suspected cause: Missing float conversion or using wrong division operator.
Suggested fix:
def divide(self, a, b):
return float(a) / float(b)
Test Details
- Test file: `tes