Repository navigation
2.35.3: require SECRET_KEY and ALLOWED_HOSTS from config.ini on test/prod - #1464
Merged
Merged
Conversation
…config.ini settings.py fell back to an in-repo SECRET_KEY and ALLOWED_HOSTS=['*'] whenever config.ini lacked them, on any environment. Both fallbacks now apply only off-server; with DJANGO_ENV of PROD or TEST, read_server_setting() raises ImproperlyConfigured for a missing, blank, or dev-default value. - tests: website/tests/test_server_config.py (7 cases, no DB) - CI: the check --deploy step writes a throwaway config.ini first - docs: DEPLOYMENT.md and CLAUDE.md describe the requirement and how to verify a server's config.ini without printing the key Do not merge until both server config files are confirmed to set both options. Part of #1460. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…t, correct docs From an independent review of this branch: - An unreadable/missing config.ini now gets its own error instead of being reported as a missing option; the startup CONFIG_FILE line says so too (the old `if not config` was never true). - parse_allowed_hosts(): an ALLOWED_HOSTS that parses to no hostnames raises on PROD/TEST (Django would start and 400 every request); '*' is accepted with a printed warning. - Docstring/CLAUDE.md no longer claim a refusal fails the deploy job: the job goes green and the site returns 502/503, so the response is to revert. - Tests: 13 cases (was 7). CI: set the cleanup trap before writing config.ini. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Part of #1460.
What changed
settings.pyfell back to development defaults forSECRET_KEYandALLOWED_HOSTSwheneverconfig.inidid not set them, in every environment. Those fallbacks are now local-dev only. WithDJANGO_ENVofPRODorTEST, a missing, blank, or dev-default value raisesImproperlyConfiguredand the site does not start.Both server config files were checked beforehand and set both options, so this changes nothing on either site today. It is a guard against a future config mistake going unnoticed.
read_server_setting()inmakeabilitylab/settings.pyparse_allowed_hosts(): strips entries, and on test/prod raises if no hostname is leftwebsite/tests/test_server_config.py: 13 cases, no DBcheck --deploystep writes a throwawayconfig.inifirst, since settings no longer load as PROD without onedocs/DEPLOYMENT.mdandCLAUDE.mddescribe the requirement and how to verify a server's file without printing the keyVerification
DJANGO_ENV=PRODwithout a key raises, and as local dev loads unchanged.After merge
A refusal to start does not fail the deploy job:
docker compose up -dreturns before the app boots, so the run goes green and the site answers 502/503. The error text only reaches the container's stdout on the Docker host. If -test is down after this deploys, revert this PR.Review
An independent review (Opus 5.5, claude-opus-5-5) led to the third commit: a separate error for an unread
config.ini, an empty-host-list check, corrected failure-mode docs, and 6 more tests.🤖 Generated with Claude Code — Fable 5.2, claude-fable-5-2