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:
parent
712612865d
commit
13b4de6d82
1 changed files with 5 additions and 1 deletions
|
|
@ -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,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue