Repository navigation
participants: one participant_reply log line for a vote or comment copied to the shadow - #3464
Merged
Merged
Conversation
…pied to the shadow The participant middleware writes one structured log line, after its decision, for a POST /api/v3/votes or POST /api/v3/comments request that carries nginx's X-Request-Id (32 lowercase hex, the rule the vote_reply line applies): how the request identified itself, the token's conversation against this one, whether this request inserted a users row or the participant row, whether it wrote an xid binding or found one, the kind of token it issued, and on a refusal which refusal. With the request id, the route and the conversation number; never a user or participant number, an xid, a token, an email, an address, a user agent or any text. Logging only: each fact is a plain assignment where it becomes true, the line is written in a finally after the reply or next(), with no await and no database work, inside a try/catch that swallows everything. No status, body, header, token, database write or ordering changes. Without the request id, or on any other route, nothing is logged. A Jest unit test drives the new anonymous person, a participant found by its token, an external id bound and an external id found, plus a refusal, asserting the exact line for each, that nothing is logged without the request id, and that a throwing logger changes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… error, not as the account refusal The participant_reply line named every XID account error "xid_account" at warn. The account check raises that error for two different things: a refusal because the account is privileged (answered 403), and a database failure while checking (answered 500, the person never classified). Both lines were identical, so a comparison would count an outage as a policy refusal. An account error answered with a status of 500 or above is now "error", written at error; "xid_account" is kept for the refusal. Nothing a request is answered changes, and no call is added or reordered: the classifier reads the status of the error it already holds, inside the line's own try. The unit test of the line now also covers each refusal (the allow-list, Treevite, the account refusal and the account check's failure, through the real account check with only its database read mocked), the errors passed on to the error handler, the second xid lookup race and the participant insert race, a token that fails to sign, tokens of each kind from another conversation, a token bound to another xid, a signed-in account, a logger that throws on the line for every one of these, and the fields left out before the conversation is resolved, with no input copied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Delphi Coverage Report
|
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 a person observes: nothing. No status, body, header, token, database write or ordering changes on any request. No schema change. One new structured log line,
participant_reply.The participant middleware writes one log line, after its decision, for a
POST /api/v3/votesorPOST /api/v3/commentsrequest that carries nginx'sX-Request-Id(32 lowercase hex, the rule thevote_replyline applies): how the request identified itself, the token's conversation against this one, whether this request inserted a users row or the participant row, whether it wrote an external-id binding or found one, the kind of token it issued, and on a refusal which refusal. With the request id, the route and the conversation number; never a user or participant number, an external id, a token, an email, an address, a user agent or any text. Without the request id, or on any other route, nothing is logged.An account check that could not be made (answered 500) is logged as
errorat error level;xid_accountat warn is kept for the account refusal (answered 403), so an outage is never counted as a policy refusal.How the participation path stays clear: logging only. Each fact is a plain assignment where it becomes true; the line is written in a
finallyafter the reply ornext(), with noawaitand no database work, inside a try/catch that swallows everything. A logger that throws changes nothing, and a test shows that for every path.Tests: a Jest unit test of the line (50 cases): the new anonymous person, a participant found by its token, an external id bound and found, each refusal (the allow-list, Treevite, the account refusal and the account check's failure through the real account check), errors passed to the error handler, the second external-id lookup race and the participant insert race, a token that fails to sign, tokens of each kind from another conversation, a signed-in account, each repeated with a throwing logger, and a privacy test that no input is copied.
🤖 Generated with Claude Code