Skip to content

Require safe paths for summarize_file MCP prompt - #5006

Merged
Widthdom merged 5 commits into
mainfrom
fix-issue4899
Jul 31, 2026
Merged

Require safe paths for summarize_file MCP prompt#5006
Widthdom merged 5 commits into
mainfrom
fix-issue4899

Conversation

@Widthdom

Copy link
Copy Markdown
Owner

Summary

  • Mark the summarize_file prompt's path argument as required in prompt discovery.
  • Return structured JSON-RPC -32602 errors for missing, null, non-string, blank, absolute, drive-prefixed, control-character-containing, or traversing paths instead of rendering an unresolved <path> placeholder.
  • Preserve spaces, Unicode, and valid POSIX backslash filename characters while normalizing Windows path separators.
  • Document the contract in both English and Japanese and add the bilingual changelog fragment changelog.d/unreleased/4899.fixed.md.

Root cause and impact

The prompt metadata described path as optional and prompts/get rendered a placeholder when it was absent. Path input also lacked prompt-specific validation. Clients could therefore receive a non-actionable template, and unsafe or platform-misclassified path text could be interpolated into the prompt. The prompt now fails early with typed errors and only renders a validated concrete indexed path.

Validation

  • dotnet test tests/CodeIndex.Tests/CodeIndex.Tests.csproj -c Release -f net8.0 -p:UseSharedCompilation=false --no-restore --filter 'FullyQualifiedName~Prompts' — 18 passed
  • dotnet test tests/CodeIndex.Tests/CodeIndex.Tests.csproj -c Release -f net9.0 -p:UseSharedCompilation=false --no-restore --filter 'FullyQualifiedName~Prompts' — 18 passed
  • dotnet build CodeIndex.sln -c Release -p:UseSharedCompilation=false --no-restore — 0 warnings, 0 errors
  • dotnet build src/CodeIndex/CodeIndex.csproj -c Debug -f net8.0 -p:UseSharedCompilation=false --no-restore — 0 warnings, 0 errors
  • dotnet format CodeIndex.sln --verify-no-changes --no-restore
  • dotnet run --project tools/CodeIndex.Changelog -- check — 74 fragments validated
  • Manual stdio MCP verification: embedded newline rejected with -32602; POSIX src\..\file.cs preserved
  • Final local index freshness/graph checks passed after updating 1,113 files and completing backfill-fold
  • Full net8 suite before the final main refresh: 10,973 passed, 7 skipped
  • Full net9 suite before the final main refresh: 10,497 passed, 420 skipped, with two unrelated load-sensitive lifecycle failures; both passed in isolated reruns and are tracked in Stabilize net9 MCP lifecycle tests under full-suite load #5001

Adversarial review

Two mandatory Codex adversarial-review rounds were completed. The review findings covered POSIX backslash preservation, control-character rejection, and platform-aware traversal validation; all reported findings were addressed with regression coverage.

Follow-up

Fixes #4899

@Widthdom
Widthdom marked this pull request as ready for review July 31, 2026 04:06
@Widthdom
Widthdom merged commit 49e72c6 into main Jul 31, 2026
12 checks passed
@Widthdom
Widthdom deleted the fix-issue4899 branch August 2, 2026 12:49
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.

Require a path for the summarize_file MCP prompt

1 participant