binarybeachio: trusted view — rename log extra key 'created' to 'is_signup'

LogRecord has a built-in `created` attribute (timestamp) and Python's
Logger.makeRecord raises KeyError("Attempt to overwrite 'created' in
LogRecord") when extra= contains it. The 500 fired AFTER user_login
already set the sessionid, so users were technically signed in but
saw a 500 page on first visit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
binarybeach 2026-05-03 21:18:49 -10:00
parent 712612865d
commit 13b4de6d82

View file

@ -250,6 +250,10 @@ class TrustedSignInEndpoint(View):
# Set Django session cookie via the existing helper.
user_login(request=request, user=user, is_app=True)
# NOTE: do NOT name extra keys after LogRecord built-in attributes
# (`name`, `created`, `levelname`, `module`, `message`, etc.) —
# Logger.makeRecord raises KeyError("Attempt to overwrite %r in LogRecord")
# on collision. Use is_signup instead of created.
log.info(
"trusted-jwt sign-in",
extra={
@ -257,7 +261,7 @@ class TrustedSignInEndpoint(View):
"sub": claims.get("sub"),
"email": email,
"tenant": claims.get("tenant"),
"created": created,
"is_signup": created,
},
)