MOD-13014: redact user data from JSONPath trace logs by gabsow · Pull Request #1605 · RedisJSON/RedisJSON · GitHub
Skip to content

MOD-13014: redact user data from JSONPath trace logs#1605

Merged
gabsow merged 1 commit into
masterfrom
tom.gabsow/MOD-13014-hide-user-data-from-trace-logs
Jun 23, 2026
Merged

MOD-13014: redact user data from JSONPath trace logs#1605
gabsow merged 1 commit into
masterfrom
tom.gabsow/MOD-13014-hide-user-data-from-trace-logs

Conversation

@gabsow

@gabsow gabsow commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Background

MOD-13014 removed user data from RedisJSON errors, but left the JSONPath engine's trace! logs untouched. Those traces still emit user data — document values, query literals, evaluated terms and path trackers — and trace! maps to Redis' debug log level (log::Level::TraceRedisLogLevel::Debug), so they reach the server log whenever loglevel debug is set. Example leftover:

trace!("calc_internal v {:?}", &v);

What this does

Mirrors Redis core's hide-user-data-from-log server config (a MODIFIABLE_CONFIG bool; core redacts command args / key values from its logs and crash reports when it's on). The redis-module crate has no binding for it, so we cache it ourselves:

  • json_path: a cached AtomicBool (default false, matching core) with hide_user_data_from_log() / set_hide_user_data_from_log(), and a trace_user_data! macro that suppresses the message when the flag is on. The 9 user-data-leaking traces (filter terms, evaluated values, sub-filters, path tracker, document v) now use it. Structural traces (grammar rule names, first_result bool, operator token, "missing operand" diagnostics) stay on plain trace!.
  • redis_json: reads the config via CONFIG GET at module load (sync_hide_user_data_from_log, handles RESP2 array + RESP3 map, defaults to false on older Redis lacking the config) and refreshes it on CONFIG SET via a #[config_changed_event_handler].

When hide-user-data-from-log is enabled, no user data reaches the log; when off (the default), tracing is unchanged.

Testing

  • cargo build for json_path + redis_json
  • cargo clippy --all-targets -- -D warnings (the CI command) — clean
  • All 86 json_path unit tests + integration tests pass, including a new regression test asserting the gate never changes query results (only whether we log)

🤖 Generated with Claude Code


Note

Low Risk
Logging-only gating with no change to query semantics; regression test covers result parity when the flag toggles.

Overview
Aligns JSONPath debug/trace logging with Redis core’s hide-user-data-from-log so document values, filter terms, and path trackers are not written to the server log when that config is enabled.

The json_path crate adds a cached AtomicBool (default false) with set_hide_user_data_from_log / hide_user_data_from_log, a trace_user_data! macro, and switches the sensitive trace! sites in filter evaluation and calc_internal to use it. Structural traces (operators, missing operands, booleans) stay on plain trace!.

redis_json reads the setting via CONFIG GET at load (RESP2 array or RESP3 map, default false if missing) and refreshes on CONFIG SET through a config_changed_event_handler. A unit test asserts the flag only affects logging, not query results.

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

@gabsow gabsow requested a review from AvivDavid23 June 21, 2026 11:53
@gabsow gabsow force-pushed the tom.gabsow/MOD-13014-hide-user-data-from-trace-logs branch from 2995abc to b09a381 Compare June 23, 2026 12:36
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

MOD-13014 removed user data from errors but left the JSONPath engine's
trace logs, which still emitted document values, query literals and paths
at Redis `debug` log level (trace! maps to RedisLogLevel::Debug).

Gate those traces behind a cached mirror of Redis core's
`hide-user-data-from-log` server config: a new `trace_user_data!` macro
suppresses the message when the flag is on. The module reads the config
at load and refreshes it on CONFIG SET via a config-changed event
handler. Structural traces (grammar rules, "missing operand"
diagnostics) stay on plain trace! and are unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gabsow gabsow force-pushed the tom.gabsow/MOD-13014-hide-user-data-from-trace-logs branch from b09a381 to ab7564d Compare June 23, 2026 12:51
@gabsow gabsow merged commit 269d0b0 into master Jun 23, 2026
62 checks passed
@gabsow gabsow deleted the tom.gabsow/MOD-13014-hide-user-data-from-trace-logs branch June 23, 2026 13:07
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.

2 participants