Skip to content

[MOD-17631] Add a hide_user_data_from_log accessor to global_config - #10924

Merged
memark merged 5 commits into
masterfrom
memark-hide-user-data-accessor
Aug 17, 2026
Merged

memark merged 5 commits into
masterfrom
memark-hide-user-data-accessor

Conversation

@memark

@memark memark commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Describe the changes in the pull request

  1. Current: global_config ([MOD-17631] Add safe global_config crate #10915) covers the settings Rust already read, but not hideUserDataFromLog — the flag that decides whether index, field and key names and query terms are obfuscated before they reach the log. Every one of its ~40 readers is still in C.
  2. Change: adds a hide_user_data_from_log() accessor alongside the existing ones. It is a plain bool field, so it goes through the same macro and inherits the crate's shared safety argument.
  3. Outcome: internal-only — nothing reads it yet. It is the prerequisite for porting a logging path to Rust without either a raw read of the static or a C helper to ask.

Which additional issues this PR fixes

  1. MOD-17631

Main objects this PR modified

  1. global_config — one new entry in the config_accessors! invocation.

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

Release Notes

  • This PR requires release notes
  • This PR does not require release notes

Worth a reviewer's attention

Unlike the settings already exposed, this one is not an FT.CONFIG knob: it is the
hide-user-data-from-log Redis server configuration, which onUpdatedHideUserDataFromLogs
mirrors into RSGlobalConfig from the config-change event. The doc comment says so, so that a
reader does not go looking for it in FT.CONFIG GET.

Stacked on #10915; review that one first, and this diff on its own is six lines.

@codecov

codecov Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.19%. Comparing base (611be9e) to head (82b3526).

Additional details and impacted files
@@                       Coverage Diff                        @@
##           memark-global-config-wrapper   #10924      +/-   ##
================================================================
+ Coverage                         78.87%   82.19%   +3.32%     
================================================================
  Files                               636      636              
  Lines                             82247    82247              
  Branches                          37485    37485              
================================================================
+ Hits                              64870    67607    +2737     
+ Misses                            17030    14293    -2737     
  Partials                            347      347              
Flag Coverage Δ
flow 84.35% <ø> (+6.95%) ⬆️
unit 55.75% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@memark memark mentioned this pull request Aug 14, 2026
1 of 4 tasks
memark and others added 5 commits August 14, 2026 15:30
Rust code that wants a RediSearch setting has to read the RSGlobalConfig
extern static, which is unsafe at every call site. Six such reads had grown
across four crates, each carrying its own safety argument, and those arguments
disagreed with src/config.c: numericCompress, prioritizeIntersectUnionChildren
and maxAggregateResults are all registered without
REDISMODULE_CONFIG_IMMUTABLE, so CONFIG SET can change them while queries run,
yet the comments claimed the fields were fixed at load time.

The new crate holds the read in one place. It hands back RSConfig by value
rather than a reference, because a &'static RSConfig would assert that nothing
writes the static while it lives, which CONFIG SET violates from client threads.
The copy is a plain unsynchronised load, matching what the C readers of the same
fields do; it can tear against a concurrent write, and removing that race needs
the C side to store the fields atomically.

Returning the whole struct also lets a caller that needs several settings take
one snapshot instead of one read per field, so an operation cannot observe a
setting changing halfway through. query_eval_ffi::eval_config does exactly that.

Co-Authored-By: Claude Opus 5 <[email protected]>
Review of the wrapper turned up three claims that overstate what a by-value
snapshot buys. `get`'s SAFETY comment established liveness and the absence of a
reference but not the third precondition for reading a `static mut`, that no
other thread writes it — which is exactly the one that does not hold, as the
doc comment directly above it already said. The comment now names the race
instead of leaving the two in contradiction.

For the same reason a snapshot cannot make an operation immune to a concurrent
`CONFIG SET`: the struct copy is not atomic, so it narrows the window rather
than closing it. `eval_config` additionally called itself the single point
where the evaluator reads the global config, which `resolve_scorer` disproves
two functions further down.

Also mark `get` `#[inline]`, so that a caller wanting one field does not pay
for an out-of-line call returning the whole struct in builds without LTO.

Co-Authored-By: Claude Opus 5 <[email protected]>
`global_config::get()` returned the whole `RSConfig`. The copy is not atomic,
so it did not make the fields it returned agree with one another, while
copying a large struct and handing back owned pointers no caller had asked
for — among them `defaultScorer`, which `FT.CONFIG SET DEFAULT_SCORER` frees.

Replace it with one accessor per field, generated from a macro so a new field
cannot be added without the shared safety argument covering it.

`default_scorer` is written out rather than generated: it returns
`Option<NonNull<c_char>>`, putting the unset case in the type instead of
leaving every caller to null-check, and its doc carries the hazard no pointer
type can express — the string can be freed while a caller still holds it.

Co-Authored-By: Claude Opus 5 <[email protected]>
The `hide-user-data-from-log` Redis server configuration decides whether
index, field and key names and query terms are obfuscated before they are
logged. Reading it through the crate keeps the Rust side of the logging
paths free of a raw read of the `RSGlobalConfig` static.

Co-Authored-By: Claude Opus 5 <[email protected]>
@memark
memark force-pushed the memark-hide-user-data-accessor branch from 88bd547 to 82b3526 Compare August 14, 2026 13:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82b35265bf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@memark
memark requested a review from daxhuiberts August 14, 2026 13:43
@sonarqubecloud

Copy link
Copy Markdown

@memark
memark added this pull request to the merge queue Aug 17, 2026
Base automatically changed from memark-global-config-wrapper to master August 17, 2026 12:23
Merged via the queue into master with commit 7e01ba5 Aug 17, 2026
65 checks passed
@memark
memark deleted the memark-hide-user-data-accessor branch August 17, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants