Skip to content

fix(json): keep dots in SetFromDirectory keys - #603

Open
pcbeingused33 wants to merge 1 commit into
redis:masterfrom
pcbeingused33:fix/json-setfromdirectory-dotted-path
Open

pcbeingused33 wants to merge 1 commit into
redis:masterfrom
pcbeingused33:fix/json-setfromdirectory-dotted-path

Conversation

@pcbeingused33

Copy link
Copy Markdown
Contributor

JSON().SetFromDirectory / SetFromDirectoryAsync store documents under the wrong key when the path of a file contains a dot anywhere before the .json extension.

Root cause: the key is built with filePath.Substring(0, filePath.IndexOf(".")), which cuts the path at its first dot instead of at the extension. For Base.Dir/v1.2/json.File1.json the key becomes Base, so every file under that directory is written to the same key and overwrites the previous one. A relative path that starts with ./ yields an empty key.

Fix: remove only the extension with Path.ChangeExtension(filePath, null), in both the sync and async implementations. Keys for paths without extra dots are unchanged.

Test: TestSetFromDirectoryWithDotsInPath and TestSetFromDirectoryWithDotsInPathAsync load a file from a directory tree with dots in the directory and file names and read it back under <path without .json>. Both fail before the change (the key does not exist) and pass after. Run on net8.0 against a standalone Redis 8 server, together with the existing TestSetFromDirectory* tests; the cluster variants were skipped locally.

Disclosure: this change was prepared with the assistance of an AI tool (Claude).

SetFromDirectory and SetFromDirectoryAsync derived the key by cutting the
file path at its first dot, so a dot in a directory or file name (or a
leading "./") truncated the key. Only the file extension is removed now.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T08:59:32.002603Z 7fca7b2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
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