Skip to content

Fix panic when passing @ response file argument to CLI#3859

Merged
RyanCavanaugh merged 6 commits into
mainfrom
copilot/fix-file-argument-crash
May 21, 2026
Merged

Fix panic when passing @ response file argument to CLI#3859
RyanCavanaugh merged 6 commits into
mainfrom
copilot/fix-file-argument-crash

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

tsgo @ and tsgo @blah panic because the response file path is passed to vfs.ReadFile without being made absolute first.

  • Thread currentDirectory from ParseCommandLine/ParseBuildCommandLine through parseCommandLineWorker into the commandLineParser struct
  • Call tspath.GetNormalizedAbsolutePath(fileName, p.currentDirectory) in parseResponseFile before reading
  • Add TestResponseFileDoesNotPanic covering both empty (@) and relative (@blah) cases

Copilot AI linked an issue May 15, 2026 that may be closed by this pull request
The CLI crashed with a panic when passing `@` or `@filename` because the
response file path was passed directly to vfs.ReadFile without being made
absolute first. Now parseResponseFile uses tspath.GetNormalizedAbsolutePath
to convert the filename to an absolute path using the current directory.

Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CLI crash when handling file argument @ Fix panic when passing @ response file argument to CLI May 15, 2026
Copilot AI requested a review from RyanCavanaugh May 15, 2026 17:45
Comment thread internal/tsoptions/export_test.go Outdated
decls []*CommandLineOption,
commandLine []string,
fs vfs.FS,
currentDirectory ...string,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot why is this ...string instead of just a singular parameter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No good reason — I used variadic to avoid updating the existing call site that omitted it, but that's not worth the indirection. Changed to a plain string parameter and added the "" argument at the existing call site.

…lain string

Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>

// f.workerDiagnostic is either defined or set to default pointer in `createSubScenario`
parsed := tsoptions.ParseCommandLineTestWorker(f.optDecls, f.commandLine, osvfs.FS())
parsed := tsoptions.ParseCommandLineTestWorker(f.optDecls, f.commandLine, osvfs.FS(), "")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this test should really have a CWD, not empty

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed to "/" — these tests use osvfs.FS() with file paths like 0.ts that aren't real, so a real working directory isn't meaningful, but "/" is a valid absolute path.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If these are osvfs, then no, / is wrong on Windows! Think again!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right — switched to t.TempDir() which returns a valid absolute path on any platform.

@RyanCavanaugh
Copy link
Copy Markdown
Member

@copilot address CR comments

@RyanCavanaugh RyanCavanaugh marked this pull request as ready for review May 15, 2026 19:11
Copilot AI review requested due to automatic review settings May 15, 2026 19:11
RyanCavanaugh and others added 2 commits May 15, 2026 12:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes a panic in tsgo when a response file argument (@ or @blah) is passed without an absolute path, by threading currentDirectory through the command line parser so the response file path can be normalized before being read.

Changes:

  • Added currentDirectory field to commandLineParser and propagated it through ParseCommandLine, ParseBuildCommandLine, and parseCommandLineWorker.
  • Normalized the response file name to an absolute path in parseResponseFile before reading.
  • Added TestResponseFileDoesNotPanic covering both empty and relative response file paths; updated ParseCommandLineTestWorker signature accordingly.
Show a summary per file
File Description
internal/tsoptions/commandlineparser.go Threads currentDirectory through the parser and normalizes the response file path before reading.
internal/tsoptions/export_test.go Adds currentDirectory parameter to the test worker helper.
internal/tsoptions/commandlineparser_test.go Adds regression tests for @ and @blah cases and updates existing call site.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

Copy link
Copy Markdown
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

This fix seems fine enough?

@RyanCavanaugh
Copy link
Copy Markdown
Member

@copilot resolve merge conflicts

…ment-crash

# Conflicts:
#	internal/tsoptions/commandlineparser_test.go

Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
@RyanCavanaugh RyanCavanaugh added this pull request to the merge queue May 21, 2026
Merged via the queue into main with commit 6b34cd4 May 21, 2026
21 checks passed
@RyanCavanaugh RyanCavanaugh deleted the copilot/fix-file-argument-crash branch May 21, 2026 14:44
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.

File argument of @ crashes CLI

5 participants