Skip to content

test: add regression guard for chat title masking - #24584

Merged
johnstcn merged 2 commits into
mainfrom
fix/chat-title-audit-followups
Apr 22, 2026
Merged

johnstcn merged 2 commits into
mainfrom
fix/chat-title-audit-followups

Conversation

@johnstcn

Copy link
Copy Markdown
Member

Follow-up to #24564 addressing unresolved review findings.

  • DEREM-1: Add Test_diff/Chat/TitleMasked to enterprise/audit/diff_internal_test.go so flipping title back to ActionTrack fails loudly. Verified: the case passes today, fails with a clear diff after flipping to ActionTrack, passes again after reverting.
  • DEREM-4: Inline comment at coderd/audit/request.go:138 explaining why ResourceTarget for database.Chat returns a UUID prefix instead of the title.
  • DEREM-5: Trailing comment on enterprise/audit/table.go title entry, matching the surrounding ActionSecret comment style.

Won't-fix, with rationale (per user):

  • DEREM-2 (8-char prefix collision risk): resource_target is a display hint, not an identifier; the full UUID lives in resource_id.
  • DEREM-3 (named constant for [:8]): single call site; extracting would be ceremony.
  • DEREM-6 (PR title misleading): merged PR title is immutable.
  • DEREM-7 (historical log redaction): the offending version only shipped to dogfood for a couple of hours and not to customers.
Implementation plan

See .agents/plans/derem-24564-followups.md in the branch history (not committed).
Key insight from the refine-plan pass: a first-draft test in coderd/exp_chats_test.go would not have guarded the regression because MockAuditor.diff is a no-op stub. The real diff logic lives in enterprise/audit/diff.go::diffValues, and Test_diff is the right home, next to the existing GitSSHKey.private_key and User.hashed_password masking cases.

🤖

Chat titles are masked in audit diffs via ActionSecret (PR #24564).
Add a Test_diff case so flipping title back to ActionTrack fails loudly,
and document the rationale inline in coderd/audit/request.go and
enterprise/audit/table.go.

Coder Agents generated.
@johnstcn johnstcn changed the title test(enterprise/audit): regression-guard chat title masking test: regression-guard chat title masking Apr 21, 2026
@johnstcn
johnstcn marked this pull request as ready for review April 21, 2026 17:09
@johnstcn
johnstcn requested a review from mafredri April 21, 2026 17:09

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean follow-up that does exactly what it promises: a regression test for the ActionSecret annotation on Chat.title, plus two inline comments documenting the security rationale. The test is solid, exercises the real production audit table via diffValues, and catches both the ActionTrack and ActionIgnore regression vectors in a single assertion.

1 P3, 2 Nit. No blockers.

The commit scope enterprise/audit doesn't cover coderd/audit/request.go. The PR title correctly omits scope, so this only affects git log readers. The commit subject "regression-guard" reads better in imperative: "add regression guard for chat title masking."

"Two failure modes guarded with one assertion. That's efficient." — Bisky

🤖 This review was automatically generated with Coder Agents.

Comment thread enterprise/audit/table.go Resolved
Comment thread coderd/audit/request.go Resolved
Comment thread coderd/audit/request.go Resolved
@johnstcn johnstcn changed the title test: regression-guard chat title masking test: add regression guard for chat title masking Apr 22, 2026

@mafredri mafredri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice!

@johnstcn
johnstcn enabled auto-merge (squash) April 22, 2026 10:50
@johnstcn
johnstcn merged commit 38f5d3f into main Apr 22, 2026
26 checks passed
@johnstcn
johnstcn deleted the fix/chat-title-audit-followups branch April 22, 2026 10:52
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants