Skip to content

fix(#7884): sticky.Post never edits a comment when identity is unresolved - #7936

Merged
waynesun09 merged 1 commit into
mainfrom
agent/7884-sticky-identity-check
Oct 1, 2026
Merged

waynesun09 merged 1 commit into
mainfrom
agent/7884-sticky-identity-check

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

sticky.Post (internal/sticky/sticky.go) resolved the poster's login via forge.Client.GetAuthenticatedUser and, on failure, logged a warning and continued with an empty login. FindMarkedComment skipped its author filter whenever the login was empty, so it matched the first comment carrying the marker regardless of author, meaning an unverified (potentially spoofed) comment could be edited in-place. #7243/#7916 already closed this gap for postTrackerStickyComment; this brings sticky.Post (used by post-comment / post-review) to the same rule.

  • resolveBotUser resolves the login with a short retry (package-level botUserLookupBackoff, tests shorten it; honours context cancellation), mirroring resolveTrackerSelf in internal/cli/issues.go. The retry logic is kept local to internal/sticky (not shared) since internal/cli imports this package.
  • Post now resolves identity before listing or writing anything. If it can't be resolved, it returns an error naming the cause and calls neither UpdateIssueComment nor CreateIssueComment, including on dry run, so dry-run output never claims an edit would occur when none safely could.
  • FindMarkedComment now treats an empty botUser as "match nothing" (previously "match any author"), requiring an exact author match plus the marker.

Testing

  • go test ./internal/sticky/... and go test ./internal/cli/... (both pass; two pre-existing failures in internal/cli, TestPostScriptEnv_NoSchemaAppendedWhenEmpty and ...WhenNoValidationLoop, are unrelated to this change and reproduce on main before this commit).
  • go vet ./..., gofmt -l on changed files.
  • pre-commit run could not fetch its remote hook repos in this sandbox (network policy); the applicable local-equivalent checks (gofmt, go vet, trailing whitespace, EOF newline, merge-conflict markers, line endings, secret scan) were run directly instead.
  • New/updated tests in internal/sticky/sticky_test.go: inverted TestFindMarkedComment_EmptyBotUser; added persistent-failure, transient-failure-then-success, planted-marker-alongside-own-comment, only-planted-comment, and dry-run-with-unresolved-identity cases.

Scope

internal/cli/issues.go (resolveTrackerSelf / postTrackerStickyComment) is intentionally untouched. It already has its own equivalent protection from #7916.


Closes #7884

Post-script verification

  • Branch is not main/master (agent/7884-sticky-identity-check)
  • Secret scan passed (gitleaks — 2d56b14f8b667ff2c922f0898126936b9fd4b41a..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

…lved

sticky.Post resolved the poster's login with GetAuthenticatedUser and,
on failure, logged a warning and continued with an empty login.
FindMarkedComment skipped its author filter whenever botUser was
empty, so it matched the first comment carrying the marker regardless
of who wrote it, letting an unverified (and potentially spoofed)
comment get edited in-place. #7243/#7916 already closed this gap for
postTrackerStickyComment; this brings sticky.Post (used by
post-comment / post-review) to the same rule.

Changes in internal/sticky/sticky.go:
* Added resolveBotUser, which retries a failed or empty
  GetAuthenticatedUser lookup per a package-level
  botUserLookupBackoff (tests shorten it), honouring ctx
  cancellation. This mirrors resolveTrackerSelf in
  internal/cli/issues.go, but is kept local to this package since
  internal/cli imports sticky and sharing it would create an import
  cycle.
* Post now calls resolveBotUser before listing or writing anything.
  If the login can't be resolved, it returns an error naming the
  cause (wrapping the lookup error) and calls neither
  UpdateIssueComment nor CreateIssueComment, including on dry run,
  so dry-run output never implies an edit would occur when none
  safely could.
* FindMarkedComment now treats an empty botUser as "match nothing"
  instead of "match any author," and requires an exact author match
  plus the marker.

Tests in internal/sticky/sticky_test.go:
* Inverted TestFindMarkedComment_EmptyBotUser to assert nil instead
  of matching any author.
* Added coverage for a persistent identity-lookup failure (errors,
  posts/edits nothing), a transient failure that succeeds on retry
  (edits the bot's own comment), a planted marker comment alongside
  the bot's own comment (only the bot's comment is edited), a lone
  planted comment (a new comment is created and the planted one is
  untouched), and dry run with an unresolved identity (errors,
  doesn't claim an edit would happen).
* flakyAuthClient wraps forge.Client to fail GetAuthenticatedUser a
  configurable number of times before succeeding, since FakeClient's
  Errors map isn't a call-sequence.
* Set AuthenticatedUser on the fake client in TestPost_DryRun and
  TestPost_DryRunExisting, which previously relied on the degraded
  fallback (an empty login) succeeding.

Scope: internal/cli/issues.go (and its resolveTrackerSelf /
postTrackerStickyComment) is untouched; that package already has its
own equivalent, added by #7916, and the issue asks to keep the retry
local to internal/sticky.

Closes #7884
@fullsend-ai-coder
fullsend-ai-coder Bot requested a review from a team as a code owner October 1, 2026 19:18
@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Triggers review agent dispatch label Oct 1, 2026
@fullsend-ai-review

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Ended 7:20 PM UTC

Commit: 0f743d8 · View workflow run →

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 7:21 PM UTC · Completed 7:31 PM UTC

Commit: 0f743d8 · View workflow run →

Runtime: pi · Model: openai/gpt-6.1-sol → gpt-6.1-sol · Effort: high · Cost: $1.57

@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/sticky/sticky.go 91.66% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@fullsend-ai-review fullsend-ai-review Bot added the risk/low PR risk: low label Oct 1, 2026
@fullsend-ai-review

Copy link
Copy Markdown

Risk Assessment: low (1/5)

Details

Scoped two-file bug fix by a bot author, with one test file, no protected-path changes, and low historical churn; the diff aligns with the linked security issue despite changing existing behavior without a feature flag.

@fullsend-ai-review

Copy link
Copy Markdown

Looks good to me


Labels: This fixes an existing sticky-comment identity-check defect that could allow edits to another author's marker comment.

@fullsend-ai-review fullsend-ai-review Bot added ready-for-merge All reviewers approved — ready to merge type/bug Confirmed defect in existing behavior security Security threat model and related concerns labels Oct 1, 2026
@waynesun09
waynesun09 added this pull request to the merge queue Oct 1, 2026
Merged via the queue into main with commit 51d07aa Oct 1, 2026
101 of 102 checks passed
@waynesun09
waynesun09 deleted the agent/7884-sticky-identity-check branch October 1, 2026 21:48

This branch was previously deployed

1 inactive deployment
dev — 0f743d85 Deployed Oct 1, 2026 by fullsend-ai-coder[bot] via behaviour #14875
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-merge All reviewers approved — ready to merge ready-for-review Triggers review agent dispatch risk/low PR risk: low security Security threat model and related concerns type/bug Confirmed defect in existing behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sticky.Post: never edit a marker comment when the poster's identity cannot be resolved

1 participant