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

MOD-13014: redact user data from JSONPath trace logs [8.10]#1608

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

MOD-13014: redact user data from JSONPath trace logs [8.10]#1608
gabsow merged 1 commit into
8.10from
tom.gabsow/MOD-13014-hide-user-data-from-trace-logs-8.10

Conversation

@gabsow

@gabsow gabsow commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Cherry-pick of #1605 onto 8.10.

Background

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

What this does

Mirrors Redis core's hide-user-data-from-log server config. The redis-module crate has no binding for it, so we cache it:

  • 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. User-data-leaking traces (filter terms, evaluated values, sub-filters, path tracker, document v, unknown function names) use it; structural traces (grammar rule names, diagnostics, operator tokens) stay on plain trace!.
  • redis_json: reads the config via CONFIG GET at module load and refreshes it on CONFIG SET via a #[config_changed_event_handler]. Defaults to false on older Redis lacking the config.

Testing

  • cargo fmt -- --check, cargo clippy --all-targets -- -D warnings — clean
  • All json_path tests pass, including a regression test asserting the gate never changes query results

🤖 Generated with Claude Code


Note

Low Risk
Logging-only gating with no query semantics changes; module init and CONFIG handler add minimal operational surface.

Overview
JSONPath debug/trace logs could still leak document values, filter terms, and path trackers when loglevel debug was set. This PR aligns that behavior with Redis core’s hide-user-data-from-log server setting.

json_path adds a cached AtomicBool (default false), set_hide_user_data_from_log / hide_user_data_from_log, and a trace_user_data! macro that skips logging when the flag is on. Sensitive traces in filter evaluation, calc_internal, and unknown function names use the macro; structural diagnostics keep plain trace!.

redis_json reads the config via CONFIG GET at module init, refreshes on CONFIG SET through a config_changed_event_handler, and calls sync_hide_user_data_from_log so the engine stays in sync.

A unit test asserts toggling the flag does not change query results—only log output.

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

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>
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

@gabsow gabsow merged commit d246d9d into 8.10 Jun 23, 2026
62 checks passed
@gabsow gabsow deleted the tom.gabsow/MOD-13014-hide-user-data-from-trace-logs-8.10 branch June 23, 2026 14:27
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