Repository navigation
fix(preview): only update preview comments written by the token's own identity - #1361
Conversation
… identity Signed-off-by: BryanFRD <bryanferrando59@gmail.com>
| fn wrote(&self, comment: &serde_json::Value) -> bool { | ||
| let author = &comment["user"]; | ||
| match self { | ||
| Self::Login(login) => author["login"].as_str() == Some(login), |
There was a problem hiding this comment.
Nit: with an integration token, AnyBot still matches a marked comment from a different app (e.g. another bot quoting the marker). It now wins as the most recent one, and the PATCH then fails with 403, which is the same failure this PR fixes, only narrower. Not blocking since /user can't identify an installation token. If you want to close it, have the update path fall back to create_comment on a 403.
| tracing::warn!( | ||
| "Warning: the token cannot read its own user, posting a new note instead of updating one" | ||
| ); |
There was a problem hiding this comment.
Nit: the other Warning: in this file is rendered with .yellow(). Matching that style:
| tracing::warn!( | |
| "Warning: the token cannot read its own user, posting a new note instead of updating one" | |
| ); | |
| tracing::warn!( | |
| "{}", | |
| "Warning: the token cannot read its own user, posting a new note instead of updating one" | |
| .yellow() | |
| ); |
|
Ready to merge. The review approved this PR with two non-blocking suggestions. Formal verification did not run: that step failed and returned no result, so nothing is verified formally. The change makes preview comment lookup match only comments written by the token's own identity on GitHub, Gitea and GitLab. If Suggestions
Formal verification
|
## [7.35.2] - 2026-10-31 ### Bug Fixes - fix(preview): only update preview comments written by the token's own identity (#1361)
Closes #1345
find_commentmatched the first comment carrying the invisible marker, whoever wrote it, so a human comment containing it got overwritten and the real preview went stale.It now resolves the token's identity with
GET /user(only when a marked comment exists) and returns the most recent marked comment written by that identity. A 5xx on that lookup fails the step with a warning rather than guessing.GitLab had the same bug, so it gets the same fix even though the issue only names GitHub and Gitea.
When
/userreturns 401/403, the identity is unknown:GITHUB_TOKEN, app installation tokens): matches any author of typeBot. This differs from thegithub-actions[bot]/ferrflow[bot]list suggested in the issue, which would post a new comment on every push for a custom GitHub App. Humans are protected, but another bot's comment carrying the marker can still be matched.The GraphQL
viewerquery was not used: its behaviour with integration tokens could not be confirmed, and{api_base}/graphqlis wrong on GHES.Tested against the fake forge server only. The 403 for
GITHUB_TOKENon/userwas not exercised on a real runner.