Repository navigation
fix: per-algorithm JWT secret minimum; domain exceptions mapped once; datetime polish - #14
Merged
Merged
Conversation
A flat 32-byte minimum let an HS384 or HS512 deployment start with a key shorter than the hash it drives, which PyJWT 2.15 warns about on every operation. config.minimum_secret_bytes() returns the RFC 7518 section 3.2 minimum per algorithm (32, 48, 64); the startup check uses it and names the algorithm and the generator command in its message. decode_access_token passes enforce_minimum_key_length so PyJWT's own rule is an error rather than a warning, a second line behind the startup check. The function is the first piece of startup validation with a test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
IdentifierTakenError (409) and PasswordVerificationError (400) are handled by app-level exception handlers in main.py; the four routes that caught them by hand now re-raise any AppError and keep only the branch that logs an unexpected failure. Same codes, same bodies; the self-service and registration tests pin them. The services stay HTTP-free. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
utc_now() uses datetime.UTC, the 3.11+ alias of timezone.utc, which reads as intended. UserResponseSchema declares created_at and updated_at as AwareDatetime, the contract SQLModel's UTCDateTime fulfils. The setup guide gains a note on `python -m asyncio ps|pstree`, new in 3.14, for a hung worker. The changelog records which 3.14 features were evaluated and left unused and why, so the question need not be reopened. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Oct 9, 2026
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.
What this PR does
Third and last PR of the "use the new stack" plan. Three small commits, one concern each.
1.
fix(auth): the secret minimum follows the algorithmconfig.pyenforced a flat 32 bytes, right for HS256 but short for HS384 (48) and HS512 (64), and PyJWT 2.15 warns on every sign and verify when the key is shorter than the hash it drives (RFC 7518 section 3.2).config.minimum_secret_bytes(algorithm)returns the per-algorithm minimum, the startup check uses it, and the message names the algorithm and the generator command.decode_access_tokenalso passes PyJWT'senforce_minimum_key_length, so the library's own rule is an error rather than a warning, a second line behind the startup check. Checked by hand: HS512 with a 40-byte secret now refuses to start. This is the first piece of startup validation that is a tested function; the Known Issues entry says so.2.
refactor: domain exceptions mapped onceIdentifierTakenError(409) andPasswordVerificationError(400) are handled by app-level exception handlers inmain.py. The four routes that caught them by hand now re-raise anyAppErrorand keep only the branch that logs an unexpected failure. Same codes, same bodies; the existing tests pin them. (FastAPI 0.137's release notes list per-router exception handlers under planned;APIRouterhas no such parameter, so app-level is the right tool.)3.
chore: datetime polish and the Python 3.14 notesutc_now()usesdatetime.UTC;UserResponseSchemadeclarescreated_atandupdated_atasAwareDatetime, the contract SQLModel'sUTCDateTimefulfils. The setup guide gains a note onpython -m asyncio ps|pstree <pid>, new in 3.14, for a hung worker. The changelog records which 3.14 features were evaluated and left unused, and why: template strings, deferred annotations, multiple interpreters and free-threading,compression.zstd,functools.Placeholder. Adopted across the plan:uuid.uuid7()(#12), PEP 758 via Black, the asyncio introspection commands.Verified
black --check,flake8,mypypass; 40 database-free tests pass (four new for the secret minimum); 83 collect.testjob.🤖 Generated with Claude Code