Skip to content

test(server): make an empty log capture unrepresentable - #123

Merged
plusky merged 1 commit into
mainfrom
fix/issue-97
Aug 18, 2026
Merged

test(server): make an empty log capture unrepresentable#123
plusky merged 1 commit into
mainfrom
fix/issue-97

Conversation

@plusky

@plusky plusky commented Aug 18, 2026

Copy link
Copy Markdown
Owner

What

capture_logs now returns a Captured newtype instead of a bare String.
There is no Deref<Target = str> and no public contains. The captured
text is reachable only through a path that has already established the
capture is non-empty: assert_logged, Captured::assert_not_contains,
or as_str (which panics on empty).

The I12 call sites in config.rs and http_auth.rs migrate off raw
logs.contains(...). A Drop guard clears the thread-local capture
slot if f panics, so the debug_assert! on entry is no longer the
only defence against residue.

Why

A negative assertion over an empty capture is vacuously true and looks
identical to a passing I12 check. #96 closed that at the then-existing
call sites by convention (assert_captured / assert_logged first).
#105 then added new I12 negatives that went back to raw contains,
guarded only by a comment. The next test cannot express the vacuous
form at all.

Touches I12 only as test evidence: the production invariant is
unchanged, and the I12 negatives are stricter (silence now fails
closed as "captured nothing").

Verification

All five AGENTS.md commands, independently, on this tree:

  • cargo fmt --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo clippy -p bugwarden --features gen --all-targets -- -D warnings
  • cargo test --workspace --all-targets --locked (all passed)
  • cargo deny check (advisories/bans/licenses/sources ok)

Adversarial review before opening:

  • captured.contains("secret") does not compile (E0599, no method
    named contains on Captured; probe reverted).
  • I12 negatives still fire on a non-empty capture that includes the
    token (assert_not_contains_fails_when_the_needle_is_present;
    config.rs / http_auth.rs use that same method on hush-key /
    WRITE / READ).
  • test(server): capture logs through one process-wide subscriber #96 messages survive: empty is captured nothing: the subscriber saw no events; missing needle is captured logs lack ….
  • No issues accepted from the review.

Closes #97.

capture_logs returned a bare String, so a future test could write
assert!(!logs.contains("secret")) against silence and go green. That
is the I12 failure mode #92/#96 closed only by convention.

Return a Captured newtype with no Deref and no contains. The text is
reachable only after the capture is shown non-empty (assert_logged,
assert_not_contains, or as_str). A Drop guard clears the thread-local
slot if f panics.
@plusky plusky added the ai-assisted Authored or substantially written with an AI coding agent label Aug 18, 2026
@plusky
plusky merged commit 4c3b998 into main Aug 18, 2026
13 checks passed
@plusky
plusky deleted the fix/issue-97 branch August 18, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Authored or substantially written with an AI coding agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

capture_logs lets a future test assert on an empty capture; make it unrepresentable

1 participant