Issue Tracking & Debugging
Load this skill when triaging bug reports, investigating issues, implementing fixes, or writing post-mortem documentation for SWS.
When to load: triaging a new issue report, investigating a regression, writing a fix for a bug, drafting a post-mortem, or reviewing a bug-fix PR.
Issue Triage
Reproducibility First
- Can you reproduce it? Follow the exact steps in the report. If unreproducible, ask the reporter for environment details (OS, architecture, SWS version, config file, TLS setup)
- Minimal reproduction: Reduce the scenario to the smallest config + file structure that triggers the bug. Strip unrelated features
- Write a failing test first: Before fixing, write a test that reproduces the bug. Use the fixture infrastructure in
tests/ and src/testing.rs
Severity Classification
| Severity |
Definition |
Response |
| P0 - Critical |
Security vulnerability, data exposure, path traversal |
Drop everything. Fix immediately. Security release |
| P1 - High |
Broken core feature (file serving, TLS), crash on start |
Fix in current sprint. Patch release |
| P2 - Medium |
Broken non-core feature, workaround exists |
Schedule in next sprint |
| P3 - Low |
Cosmetic, log message, doc typo |
Backlog. Fix when touching related code |
Root Cause Analysis
Debugging Process
- Gather evidence: Logs (
-g trace), stack traces, HTTP response headers, request URIs, config file
- Form a hypothesis: Based on the evidence, propose what might cause the bug
- Test the hypothesis: Add tracing, run reproduction, or step through with a debugger
- Identify the root cause: Find the exact line or condition that triggers the bug. Don't stop at symptoms
- Verify the fix: The reproduction test now passes. The original scenario works
Rust Debugging
- Use
tracing crate for structured logs: SWS uses tracing-subscriber. Run with -g trace for maximum detail. Log levels: ERROR (actionable), WARN (unexpected but handled), INFO (key events), DEBUG (detailed), TRACE (noisy)
- Use
dbg!() for quick inspection: Temporary, remove before committing
- Enable backtraces:
RUST_BACKTRACE=1 for panic backtraces, RUST_LIB_BACKTRACE=1 for error backtraces
HTTP Debugging
- Inspect response headers: Use
curl -v http://localhost:8787/path to see full request/response exchange
- Test with specific Accept-Encoding headers:
curl -H "Accept-Encoding: br" ... to test compression variant selection
- Check security headers:
curl -I http://localhost:8787/ | grep -i 'x-\|strict\|csp\|referrer'
- Test byte-range requests:
curl -H "Range: bytes=0-99" http://localhost:8787/file
- CORS preflight debugging:
curl -X OPTIONS -H "Origin: https://example.com" -H "Access-Control-Request-Method: GET" http://localhost:8787/
- TLS verification:
openssl s_client -connect localhost:8787 -servername localhost
File-Serving Debugging
- Path resolution issues: Check if the file exists at the resolved path. SWS logs the resolved path at
trace level
- Hidden file / symlink blocking: Verify
--include-hidden and --follow-symlinks settings (both default to false). Hidden files return 404 (stealth), symlinks return 403
- Index file resolution: If a directory returns 404 instead of an index, check
--index-files list and file existence
- MIME type issues: SWS uses
mime_guess from file extension. If the wrong Content-Type is served, check the file extension
Fix Implementation
Before Writing the Fix
Writing the Fix
- Minimal change: Fix the bug with the smallest possible code change. Do not refactor unrelated code in the same PR
- Add a regression test: The reproduction test becomes a permanent regression test
- Update documentation: If the fix changes behavior, update the relevant feature doc in
docs/content/features/
Commit Message Format
fix(scope): brief description of the fix
Detailed explanation of the root cause and the fix.
Include steps to reproduce, expected behavior, and actual behavior.
Fixes #123
scope is the affected module or feature (e.g., compression, tls, static-files). See COMMITS.md for the full convention.
Regression Prevention
- The reproduction test stays: Every bug fix adds a test that prevents the same bug from returning
- Check similar code paths: Search the codebase for patterns that could cause the same class of bug
- Add a lint rule if applicable: If a pattern caused the bug and can be detected statically, add a clippy or ESLint rule
Post-Mortem (P0/P1 only)
For critical and high-severity issues, write a brief post-mortem:
- What happened: Timeline of the incident
- Root cause: The specific code or configuration that caused it
- Impact: What users were affected and how
- Fix: What change resolved the issue
- Prevention: What process, tooling, or test prevents recurrence
Store post-mortems in docs/post-mortems/YYYY-MM-DD-title.md.
Checklist
1---2name: issue-tracking3description: Triage, debug, fix, and document issues for the Static Web Server (SWS) project — bug reports, root cause analysis, fix implementation, and regression prevention4---56# Issue Tracking & Debugging78Load this skill when triaging bug reports, investigating issues, implementing fixes, or writing post-mortem documentation for SWS.910**When to load**: triaging a new issue report, investigating a regression, writing a fix for a bug, drafting a post-mortem, or reviewing a bug-fix PR.1112## Issue Triage1314### Reproducibility First1516- **Can you reproduce it?** Follow the exact steps in the report. If unreproducible, ask the reporter for environment details (OS, architecture, SWS version, config file, TLS setup)17- **Minimal reproduction**: Reduce the scenario to the smallest config + file structure that triggers the bug. Strip unrelated features18- **Write a failing test first**: Before fixing, write a test that reproduces the bug. Use the fixture infrastructure in `tests/` and `src/testing.rs`1920### Severity Classification2122| Severity | Definition | Response |23|----------|-----------|----------|24| **P0 - Critical** | Security vulnerability, data exposure, path traversal | Drop everything. Fix immediately. Security release |25| **P1 - High** | Broken core feature (file serving, TLS), crash on start | Fix in current sprint. Patch release |26| **P2 - Medium** | Broken non-core feature, workaround exists | Schedule in next sprint |27| **P3 - Low** | Cosmetic, log message, doc typo | Backlog. Fix when touching related code |2829## Root Cause Analysis3031### Debugging Process32331. **Gather evidence**: Logs (`-g trace`), stack traces, HTTP response headers, request URIs, config file342. **Form a hypothesis**: Based on the evidence, propose what might cause the bug353. **Test the hypothesis**: Add tracing, run reproduction, or step through with a debugger364. **Identify the root cause**: Find the exact line or condition that triggers the bug. Don't stop at symptoms375. **Verify the fix**: The reproduction test now passes. The original scenario works3839### Rust Debugging4041- **Use `tracing` crate for structured logs**: SWS uses `tracing-subscriber`. Run with `-g trace` for maximum detail. Log levels: ERROR (actionable), WARN (unexpected but handled), INFO (key events), DEBUG (detailed), TRACE (noisy)42- **Use `dbg!()` for quick inspection**: Temporary, remove before committing43- **Enable backtraces**: `RUST_BACKTRACE=1` for panic backtraces, `RUST_LIB_BACKTRACE=1` for error backtraces4445### HTTP Debugging4647- **Inspect response headers**: Use `curl -v http://localhost:8787/path` to see full request/response exchange48- **Test with specific Accept-Encoding headers**: `curl -H "Accept-Encoding: br" ...` to test compression variant selection49- **Check security headers**: `curl -I http://localhost:8787/ | grep -i 'x-\|strict\|csp\|referrer'`50- **Test byte-range requests**: `curl -H "Range: bytes=0-99" http://localhost:8787/file`51- **CORS preflight debugging**: `curl -X OPTIONS -H "Origin: https://example.com" -H "Access-Control-Request-Method: GET" http://localhost:8787/`52- **TLS verification**: `openssl s_client -connect localhost:8787 -servername localhost`5354### File-Serving Debugging5556- **Path resolution issues**: Check if the file exists at the resolved path. SWS logs the resolved path at `trace` level57- **Hidden file / symlink blocking**: Verify `--include-hidden` and `--follow-symlinks` settings (both default to `false`). Hidden files return 404 (stealth), symlinks return 40358- **Index file resolution**: If a directory returns 404 instead of an index, check `--index-files` list and file existence59- **MIME type issues**: SWS uses `mime_guess` from file extension. If the wrong `Content-Type` is served, check the file extension6061## Fix Implementation6263### Before Writing the Fix6465- [ ] Is there a failing test that reproduces the bug?66- [ ] Is the root cause identified (not just the symptom)?67- [ ] Does the fix address the root cause?68- [ ] Are there other places in the codebase with the same bug pattern?6970### Writing the Fix7172- **Minimal change**: Fix the bug with the smallest possible code change. Do not refactor unrelated code in the same PR73- **Add a regression test**: The reproduction test becomes a permanent regression test74- **Update documentation**: If the fix changes behavior, update the relevant feature doc in `docs/content/features/`7576### Commit Message Format7778```79fix(scope): brief description of the fix8081Detailed explanation of the root cause and the fix.82Include steps to reproduce, expected behavior, and actual behavior.8384Fixes #12385```8687`scope` is the affected module or feature (e.g., `compression`, `tls`, `static-files`). See `COMMITS.md` for the full convention.8889## Regression Prevention9091- **The reproduction test stays**: Every bug fix adds a test that prevents the same bug from returning92- **Check similar code paths**: Search the codebase for patterns that could cause the same class of bug93- **Add a lint rule if applicable**: If a pattern caused the bug and can be detected statically, add a clippy or ESLint rule9495## Post-Mortem (P0/P1 only)9697For critical and high-severity issues, write a brief post-mortem:98991. **What happened**: Timeline of the incident1002. **Root cause**: The specific code or configuration that caused it1013. **Impact**: What users were affected and how1024. **Fix**: What change resolved the issue1035. **Prevention**: What process, tooling, or test prevents recurrence104105Store post-mortems in `docs/post-mortems/YYYY-MM-DD-title.md`.106107## Checklist108109- [ ] Bug is reproduced and understood110- [ ] Root cause identified (not just symptom)111- [ ] Failing test written before the fix112- [ ] Fix is minimal and addresses root cause113- [ ] Regression test added114- [ ] Similar code paths checked for the same bug pattern115- [ ] Commit message follows format