Skip to content

Default service_debug to False and keep Litestar's explicit AppConfig.debug - #369

Merged
lesnik512 merged 1 commit into
mainfrom
service-debug-off
Oct 29, 2026
Merged

lesnik512 merged 1 commit into
mainfrom
service-debug-off

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Closes #316.

service_debug now defaults to False, so a service that never sets it no longer returns tracebacks in error responses. The default is at instruments/base.py:16.

Litestar no longer overwrites the user's AppConfig.debug. _apply_config now sets application_config.debug = application_config.debug or service_debug. That is the first option in the issue: AppConfig(debug=True) or service_debug=True each turn debug on, and with the new default an explicit AppConfig(debug=False) stays off. I didn't take the bool | None alternative. With a False default the two can't conflict, so the extra state would only matter when service_debug=True and AppConfig(debug=False) are both set, which reads as a contradiction anyway.

FastAPI needed no change beyond the default. A user-supplied app is still left alone, and test_user_supplied_app_keeps_title_version_debug is unchanged.

Tests

Written first. These failed on main:

  • test_litestar_debug_follows_app_config_and_service_debug[default]: a default LitestarConfig() built a debug app.
  • test_litestar_debug_follows_app_config_and_service_debug[app-config-debug-off]: the issue's reproduction, AppConfig(debug=False) came out with debug True.
  • test_built_app_debug_follows_service_debug[default]: a default FastAPIConfig() built a debug app.
  • test_from_object_skips_missing_attribute, which asserted the old default and now asserts False.

The app-config-debug-on and service-debug-on cases passed on main and pin the ways to turn debug on.

The full suite passes, 557 tests at 100% coverage (just test-ci). just lint (including ty), just adr-check and just docs-build pass too. No floor changes.

Docs

configuration.md has a new "Debug mode" section with the default and what the field does on each framework. FastStream, FastMCP and the free bootstrapper don't read it.

Breaking changes

FastAPI apps built by lite-bootstrap and Litestar apps no longer run in debug mode unless asked. To keep tracebacks in error responses, for example in development, set service_debug=True, or on Litestar pass AppConfig(debug=True).

@lesnik512 lesnik512 added this to the 2.0.0 milestone Oct 29, 2026
@lesnik512
lesnik512 merged commit 75b0c87 into main Oct 29, 2026
37 checks passed
@lesnik512
lesnik512 deleted the service-debug-off branch October 29, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default service_debug to False and stop Litestar overriding an explicit AppConfig.debug

1 participant