ocr scan --path .\\dir silently selects no files on Windows
OpenCodeReview Version
dev snapshot from main at ebb69835a3a2d25468b6a68ba6092b9b8fe6bcb0 (September 28, 2026)
Operating System
Windows, running the CLI from PowerShell
Installation Method
Built from source
LLM Provider
Not applicable; this reproduces during file enumeration with --preview.
Bug Description
On Windows, a normal PowerShell relative path such as .\internal\scan makes ocr scan --path select zero files. The same directory is selected when the leading . and backslashes are removed (internal/scan), so the problem is in path normalization rather than in the repository contents.
This is easy to miss because the command exits without an error and reports No files changed.
Steps to Reproduce
From a checkout of OpenCodeReview (or any Git repository with files below a subdirectory), run:
ocr scan --preview --path '.\internal\scan'Run the equivalent selector using slash-separated repository-relative syntax:
ocr scan --preview --path internal/scan
With the current source, the first command prints:
No files changed.The second command discovers the files under internal/scan (21 files in this checkout, before the normal review-rule filtering is applied).
Expected Behavior
--path '.\internal\scan' should select the same files as --path internal/scan. Windows users commonly get the former spelling from Explorer, PowerShell completion, or Resolve-Path-style workflows.
If a path cannot be resolved, the command should report that explicitly rather than silently running with an empty selection.
Root Cause
internal/scan/provider.go normalizes selectors in this order:
p = strings.TrimPrefix(p, "./")
p = strings.TrimSuffix(p, "/")
p = filepath.ToSlash(p)For the Windows spelling .\internal\scan (without the explanatory space), the "./" prefix is not removed because the input still contains backslashes. filepath.ToSlash then turns it into ./internal/scan. filterByPaths compares that value with paths from git ls-files, such as internal/scan/provider.go, so nothing matches. A trailing Windows separator has a similar problem: internal\scan\ becomes internal/scan/ and is tested as if the directory were internal/scan/, producing a doubled slash in the child-prefix check.
Suggested Fix
Normalize platform-native separators before stripping ./ and trailing separators, or clean the path with the platform-aware path utilities first and then convert it to the slash-separated form used by Git. Please add regression coverage for at least:
internal/scan./internal/scan.\internal\scaninternal\scan\
AI/LLM Disclosure
I used OpenAI Codex to inspect the source and run the local reproduction. I checked the behavior against the CLI entrypoint and the scan provider before filing this report.
Additional Context
This is about the --path selector itself; it is not the separate Windows separator issue for --exclude and rule.json patterns. The current workaround is to use slash-separated repository-relative paths, for example --path internal/scan.
Source: alibaba/open-code-review