Skip to content

chore: fix log statement#116512

Open
joseph-sentry wants to merge 1 commit into
masterfrom
joseph-sentry/chore/fix-viewer-context-log-statement
Open

chore: fix log statement#116512
joseph-sentry wants to merge 1 commit into
masterfrom
joseph-sentry/chore/fix-viewer-context-log-statement

Conversation

@joseph-sentry
Copy link
Copy Markdown
Contributor

Summary

Fixes a bug where emitting the viewer_context_jwt.no_signing_key warning log hard-errors instead of degrading gracefully.

When SEER_API_SHARED_SECRET is not configured, encode_viewer_context raises ValueError, which is meant to be caught and logged as a warning so the request can continue. But the warning passed extra={"msg": ...}, and msg is a reserved attribute on Python's LogRecord. logging.makeRecord refuses to overwrite it and raises:

KeyError: "Attempt to overwrite 'msg' in LogRecord"

So the handler meant to swallow the missing-key case instead threw a new exception that bubbled up as an uncaught 500 on the autofix endpoints.

The fix renames the extra key from the reserved msg to reason.

Test plan

Hit a Seer-backed endpoint (e.g. autofix) locally without SEER_API_SHARED_SECRET set — the request now logs a warning and continues instead of 500ing.

ran into an issue when running this locally where emitting this log hard errored because we're setting msg when it's apparently a reserved keyword in python's log record, so we should just set this with a different key
@joseph-sentry joseph-sentry requested a review from a team as a code owner May 29, 2026 18:58
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 29, 2026
Copy link
Copy Markdown
Member

@JoshFerge JoshFerge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm weird, i thought we had a ruff rule enabled for this 🤔 G101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants