Skip to content

fix(cmd): include backslash in path detection for @ file references - #38

Open
hsusul wants to merge 1 commit into
openai:mainfrom
hsusul:fix/flagoptions-backslash-path-detection
Open

fix(cmd): include backslash in path detection for @ file references#38
hsusul wants to merge 1 commit into
openai:mainfrom
hsusul:fix/flagoptions-backslash-path-detection

Conversation

@hsusul

@hsusul hsusul commented Jul 26, 2026

Copy link
Copy Markdown

Observed Behavior

When passing an @ file reference containing backslash path separators (such as @subfolder\\unreadablefile or Windows paths without a file extension) that fails to open, embedFilesValue in pkg/cmd/flagoptions.go did not recognize \\ as a path separator. As a result, probablyFile / expectsFile evaluated to false, silently falling back to treating the unreadable file path as a raw string literal ("@subfolder\\\\unreadablefile") instead of surfacing a file read error.

Root Cause

probablyFile and expectsFile checks in pkg/cmd/flagoptions.go (lines 237 and 265) checked for . and / (strings.Contains(filename, ".") || strings.Contains(filename, "/")), but omitted \\ (strings.Contains(filename, "\\\\")).

Implementation

Updated path detection in embedFilesValue (pkg/cmd/flagoptions.go) to also check for \\ (strings.Contains(filename, "\\\\")), ensuring paths using backslashes are recognized as file references when handling unreadable file errors.

Regression Coverage

Added unit test case "non-existent file with backslash path @ prefix (error)" in pkg/cmd/flagoptions_test.go to assert that unreadable backslash path references properly return a file reading error instead of falling back to a raw string literal.

Exact Validation Commands & Results

  • go test ./pkg/cmd -run TestEmbedFiles -> Passed
  • go test ./internal/... -> Passed
  • go vet ./internal/... ./pkg/... -> Passed (clean)
  • git diff --check -> Passed (clean)

Limitations or Untested Platforms

None.

Unrelated Changes

No unrelated changes were included.

@hsusul
hsusul requested a review from a team as a code owner July 26, 2026 00:58

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the backslash path heuristic and both embedding modes; no blocking issues found. Focused TestEmbedFiles tests, go vet ./pkg/..., gofmt, and git diff --check passed. Full package tests require the repository mock server on localhost:4010, which was not running.

@markstuart-oai

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-06T01:30:44.305590Z efe9745 Manual request
🔒 Security Review Completed 2026-09-06T01:32:32.321459Z efe9745 Manual request
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: efe9745fa2

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: efe9745fa2

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

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.

3 participants