Repository navigation
Default service_debug to False and keep Litestar's explicit AppConfig.debug - #369
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #316.
service_debugnow defaults toFalse, so a service that never sets it no longer returns tracebacks in error responses. The default is atinstruments/base.py:16.Litestar no longer overwrites the user's
AppConfig.debug._apply_confignow setsapplication_config.debug = application_config.debug or service_debug. That is the first option in the issue:AppConfig(debug=True)orservice_debug=Trueeach turn debug on, and with the new default an explicitAppConfig(debug=False)stays off. I didn't take thebool | Nonealternative. With a False default the two can't conflict, so the extra state would only matter whenservice_debug=TrueandAppConfig(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_debugis unchanged.Tests
Written first. These failed on main:
test_litestar_debug_follows_app_config_and_service_debug[default]: a defaultLitestarConfig()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 withdebugTrue.test_built_app_debug_follows_service_debug[default]: a defaultFastAPIConfig()built a debug app.test_from_object_skips_missing_attribute, which asserted the old default and now asserts False.The
app-config-debug-onandservice-debug-oncases 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(includingty),just adr-checkandjust docs-buildpass too. No floor changes.Docs
configuration.mdhas 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 passAppConfig(debug=True).