litestar-debugging
Debugging
Execution Workflow
- Reproduce the issue with the smallest possible app, route, or test case.
- Identify the failing layer first: requests, routing, dependency injection, middleware, auth, responses, exception handling, or lifecycle.
- Turn on only the minimum safe diagnostics needed: local
debug=True, focused logs, or temporary assertions. - Inspect the boundary where the behavior diverges from expectation.
- Fix the root cause, remove temporary diagnostics, and add a regression test.
- Re-run the affected tests and re-check the surrounding contract for regressions.
Core Rules
- Keep
debug=Truelocal-only. - Prefer deterministic logs, assertions, and focused reproduction apps over ad hoc print debugging.
- Narrow the failing layer before changing code.
- Use request and app loggers for evidence, not speculation.
- Keep debug output free of secrets and sensitive payloads.
- Remove temporary diagnostics once the root cause is understood.
- Always codify the fix with a regression test when feasible.
Decision Guide
- Use a tiny repro app when the existing app is too large to reason about quickly.
- Use
litestar-testingclients when the bug is observable through the HTTP or websocket contract. - Use
litestar-loggingwhen the main gap is missing evidence rather than a code defect. - Use
debug=Trueonly when local traceback detail materially shortens the investigation. - Hand off to the more specific Litestar skill once the failing subsystem is clear.
Reference Files
Read only the sections you need:
- For reproduction strategy, layer isolation, and temporary diagnostic tactics, read references/reproduction-and-isolation.md.
- For common subsystem debugging patterns across requests, auth, responses, exceptions, and lifecycle, read references/subsystem-patterns.md.
Recommended Defaults
- Reproduce with the smallest route and the smallest input that still fails.
- Keep one hypothesis at a time and test it quickly.
- Add evidence before changing behavior.
- Use logs to compare expected and actual values at subsystem boundaries.
- Convert the repro into a stable test once the bug is found.
Anti-Patterns
- Leaving
debug=Trueor verbose diagnostics enabled after the fix. - Changing several subsystems at once before isolating the failure.
- Catching broad exceptions to hide symptoms instead of understanding them.
- Assuming a request, auth, or response bug without reproducing the exact contract.
- Logging secrets, tokens, or raw sensitive request bodies during debugging.
Validation Checklist
- Confirm the issue reproduces before the fix and stops reproducing after it.
- Confirm both happy-path and failure-path contracts still behave correctly.
- Confirm no sensitive values are leaked by temporary or permanent diagnostics.
- Confirm the regression test fails before the fix and passes after it.
- Confirm temporary debugging code is removed.
Cross-Skill Handoffs
- Use
litestar-loggingwhen better evidence collection is the main need. - Use
litestar-testingto codify the repro and lock the fix. - Use
litestar-requests,litestar-responses,litestar-exception-handling, orlitestar-authenticationonce the failing boundary is known. - Use
litestar-metricsonly after the runtime bug is understood and ongoing visibility is needed.
Litestar References
More from alti3/litestar-skills
litestar-responses
Build Litestar responses with typed return values, explicit Response containers, layered response classes, headers, cookies, status-code control, redirects, files, streams, server-sent events, ASGI app returns, and background tasks. Use when shaping outbound HTTP behavior, correcting response contracts, or choosing the right Litestar response primitive. Do not use for request parsing, validation, or authentication policy design.
22litestar-logging
Configure Litestar logging with `LoggingConfig`, `queue_listener`, exception logging policy, selective stack-trace suppression, standard logging, picologging, Structlog, and custom logging config subclasses. Use when establishing or refactoring application logging behavior, request-level logs, or production-safe error logging in Litestar. Do not use for metrics/tracing instrumentation or exception-response contract design.
22litestar-authentication
Implement Litestar authentication with custom authentication middleware, built-in security backends, JWT and session flows, route inclusion and exclusion rules, and typed auth context on `Request` / `ASGIConnection`. Use when establishing identity, issuing or validating credentials, or attaching authenticated user context in Litestar. Do not use for generic request parsing, broad security audits, or unrelated transport concerns.
22litestar-middleware
Design and apply Litestar middleware for cross-cutting concerns such as CORS, CSRF, allowed-host checks, compression, rate limiting, logging, sessions, request enrichment, policy enforcement, and custom ASGI pipeline control. Use when behavior must wrap broad route sets consistently across the ASGI stack. Do not use for route-specific business rules, simple response mutation better handled by lifecycle hooks, or auth/guard policy work that belongs in security-focused skills.
20litestar-routing
Design and implement Litestar routing with app/router/controller composition, handler decorators, path and parameter modeling, route indexing/reverse lookups, ASGI mounting, and layered route metadata. Use when creating or refactoring endpoint topology and URL contracts. Do not use for purely internal service logic unrelated to HTTP route structure.
18litestar-dto
Configure Litestar DTO behavior for inbound parsing and outbound serialization, including layer-scoped `dto`/`return_dto`, `DTOConfig` policies, `DTOData` update workflows, and custom `AbstractDTO` implementations. Use when API payload contracts differ from internal model structures. Do not use when internal models can be exposed safely without transformation.
18