Project 9 — Bug-Triage Assistant from Stack Traces
Paste a stack trace, get a diagnosis + fix proposal.
What You Will Learn
- Build a bug-triage assistant.
- Diagnose from stack traces.
- Propose fixes.
- Output structured JSON.
- Build a CLI wrapper.
Why This Matters
Bug triage is a daily reality. An assistant that takes a stack trace, diagnoses the root cause, and proposes a fix saves hours per week per developer.
Concept Explained
A CLI tool or Chat workflow: paste a stack trace. Copilot diagnoses root cause, identifies affected files, proposes a fix. Output as JSON for pipeline integration.
How It Works
Build a CLI script that takes a stack trace (stdin or file). Calls Copilot with a schema: {severity, category, likely_cause, suggested_fix, affected_files, confidence}. Outputs JSON.
Step-by-Step Tutorial
1. Define schema
{severity, category, likely_cause, suggested_fix, affected_files, confidence}2. Build CLI script
Read stack trace from stdin/file. Call Copilot with schema.3. Validate output
Parse JSON. Validate against schema.4. Test on real traces
Run on 10 historical stack traces. Verify diagnoses.5. Integrate with issue tracker
File issues from JSON output.Real-World Example
A team built a bug-triage assistant. Run on every error log in production. Filed issues automatically with severity, category, and suggested fix. Saved ~30 minutes per incident. Cut mean time to resolution by 40%.
Example Prompts / Commands / Code
#!/usr/bin/env python3
# triage.py
import subprocess
import json
import sys
schema = '''
Output as JSON matching this TypeScript type:
type BugAnalysis = {
severity: 'high' | 'medium' | 'low';
category: 'runtime' | 'logic' | 'security' | 'performance' | 'other';
likely_cause: string;
suggested_fix: string;
affected_files: string[];
confidence: number;
};
Output ONLY the JSON. No prose.
'''
stack_trace = sys.stdin.read()
prompt = f'Analyze this stack trace.\n\n{stack_trace}\n\n{schema}'
result = subprocess.run(['copilot', '--no-interactive', prompt],
capture_output=True, text=True)
try:
analysis = json.loads(result.stdout)
print(json.dumps(analysis, indent=2))
except:
print('Failed to parse Copilot output as JSON', file=sys.stderr)
sys.exit(1)
$ cat stack-trace.log | python3 triage.py
{
"severity": "medium",
"category": "runtime",
"likely_cause": "Null reference in user lookup when id is empty",
"suggested_fix": "Add null check before user lookup in auth/service.ts:42",
"affected_files": ["src/auth/service.ts"],
"confidence": 0.85
}
Common Mistakes
- No schema — output is unstructured prose.
- No validation — silent JSON parse failures.
- Trusting diagnoses without verification.
- Not testing on real traces.
Best Practices
- Define a clear JSON schema.
- Validate output programmatically.
- Test on 10+ historical traces.
- Verify diagnoses against actual code.
- Integrate with issue tracker for automation.
Troubleshooting
| Problem | How to Fix |
|---|---|
| JSON malformed | Add 'Output ONLY the JSON' instruction. Try different model. |
| Diagnoses are wrong | Provide more context (attach relevant files). |
Practical Exercise
Your Turn
Build a bug-triage CLI script. Test on 5 real stack traces from your codebase. Verify diagnoses against actual code.
Professional Challenge
Integrate with your issue tracker (GitHub Issues, Jira). Auto-file issues from JSON output. Measure time saved per incident.
Key Takeaways
- Bug-triage assistant takes stack trace, outputs JSON diagnosis.
- Define clear schema.
- Validate output.
- Test on real traces.
- Integrate with issue tracker for automation.
Frequently Asked Questions
Does this replace debugging?
Accuracy?
Further Reading
Official References
SEO Metadata
SEO title: Project 9 — Bug-Triage Assistant from Stack Traces
Meta description: Paste a stack trace, get a diagnosis + fix proposal.
Primary keyword: project 9
Secondary keywords: project 9 — bug-triage assistant from stack traces
Search intent: Informational
URL slug: /project-bug-triage-assistant-stack-traces-copilot
Categories: AI Tools, GitHub Copilot
Tags: GitHub Copilot, Intermediate, Project, Bug Triage, Stack Trace, Debugging, IMCSEIAN, Tutorial, IMCSEIAN
Featured image concept: IMCSEIAN lesson card for Project 9 — Bug-Triage Assistant from Stack Traces
Comments
Comments
Post a Comment