Repository navigation
fix(agent): match the Python agent in redaction, transport and flush semantics - #58
Merged
Merged
Conversation
…semantics Closes #57
This was referenced Oct 15, 2026
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.
Closes #57
I audited guard-agent-rs against the Python agent (guard-agent master) and fixed every divergence I could reproduce. Each change has a test that failed on master first.
Redaction:
Redactornow followssanitize_headers. It recurses to depth 10 and redacts anything deeper wholesale, parses JSON-looking string values, sanitizes inside them and re-dumps them with Python'sjson.dumpsformatting, redacts JSON-looking strings over 8192 characters wholesale, and applies the same rules to metric tag values. Strings that Python parses butserde_jsoncannot (lone surrogate escapes, nesting past the parser limit) are redacted wholesale instead of passing through, and theNaNandInfinityliterals are handled. The transport runs a second pass over event metadata and metric tags before serializing, plain and encrypted. The expected values intests/fixtures/sanitize_vectors.jsoncome from running the reference function on the same inputs.serde_jsongetspreserve_orderso re-dumped strings keep key order like Python.Transport and flush:
errorsuses Python truthiness. Redirects are no longer followed. GET follows the same status rules.loop_failures.flushresets on every completed loop iteration, as in the reference, instead of counting failed flushes.Existing tests that pinned the old behavior (drop does not count as sent, right half skipped, any 2xx accepted, rules loop without a project id) are updated to the reference behavior. I did not touch CHANGELOG.md because release prep owns it in this repo.
I ran fmt, clippy with
-D warnings(default and all features),cargo testandcargo test --all-features -- --include-ignoredagainst Redis,cargo docwith-D warnings, the MSRV 1.92 check and tests, cargo deny, cargo audit and the 100% line coverage gate locally.