Skip to content

fix redactSecrets stack overflow on circular references#23

Merged
jackcbrown89 merged 2 commits intomainfrom
jb-fix-redaction-recursion
Apr 14, 2026
Merged

fix redactSecrets stack overflow on circular references#23
jackcbrown89 merged 2 commits intomainfrom
jb-fix-redaction-recursion

Conversation

@jackcbrown89
Copy link
Copy Markdown
Contributor

@jackcbrown89 jackcbrown89 commented Apr 14, 2026

Use a WeakMap to track visited objects and map them to their redacted results. This prevents infinite recursion and ensures secrets are redacted even through circular reference paths.


Note

Medium Risk
Changes core redaction recursion to track and reuse seen objects/arrays; low behavioral surface area but could subtly affect identity/structure of returned objects for complex inputs.

Overview
Fixes redactSecrets to safely handle circular references by tracking visited objects/arrays in a WeakMap and reusing the already-redacted result to avoid infinite recursion.

Adds a regression test asserting circular structures are preserved (self-references point to the redacted clone) while still redacting secret strings.

Reviewed by Cursor Bugbot for commit b5409af. Bugbot is set up for automated code reviews on this repo. Configure here.

Use a WeakMap to track visited objects and map them to their
redacted results. This prevents infinite recursion and ensures
secrets are redacted even through circular reference paths.
@jackcbrown89
Copy link
Copy Markdown
Contributor Author

bugbot run

Comment thread packages/runtimeuse/src/utils.ts Outdated
Move recursive logic into a closure so the public signature stays
as the documented two-parameter form.
@jackcbrown89
Copy link
Copy Markdown
Contributor Author

bugbot run

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b5409af. Configure here.

@jackcbrown89 jackcbrown89 merged commit a74e992 into main Apr 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant