Skip to content

[Bug]: Git file paths lose leading and trailing spaces during decoding #12464

Description

@Defmon3

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

packages/contracts or packages/shared

Steps to reproduce

Git action inputs and working-tree status results trim whitespace from file paths. A path such as " leading.txt" becomes "leading.txt", which names a different file.

Both GitRunStackedActionInput.filePaths and VcsStatusLocalResult.workingTree.files[].path use a string schema that trims its input.

Related: issue #5501 reports a Files panel failure involving ProjectEntry.path; this report concerns the separate Git action and working-tree status schemas.

This is a schema-level reproduction; no filesystem setup is required.

  1. Decode this input with Schema.decodeUnknownSync(GitRunStackedActionInput):

    {
      "actionId": "action-1",
      "cwd": "/repo",
      "action": "commit",
      "filePaths": [" leading.txt", "trailing.txt "]
    }
  2. Inspect the decoded filePaths.

  3. The same transformation occurs when those paths are decoded in a valid VcsStatusLocalResult working-tree file list.

Expected behavior

File paths retain their exact characters. Empty paths remain invalid.

Actual behavior

Input:   [" leading.txt", "trailing.txt "]
Decoded: ["leading.txt", "trailing.txt"]

The decoded value identifies a different path when a filename has leading or trailing spaces. Such filenames are legal on macOS and Linux, so their working-tree status results can carry paths affected by this trimming. A complete staging or commit failure was not tested.

Impact

Minor bug or occasional failure

Version or commit

Upstream commit 9ea9c3d5d2c444133e3ddff40eecf38737951589.

Environment

Focused automated tests on Windows with Node 24.13.1 and Vitest 4.1.11. These tests decode strings; they do not create Windows files with trailing spaces.

Logs or stack traces

Both preservation assertions report:

AssertionError: expected [ 'leading.txt', 'trailing.txt' ] to deeply equal [ ' leading.txt', 'trailing.txt ' ]

Two preservation assertions fail against upstream: one for action inputs and one for status results. Two empty-path rejection assertions pass.

A local fix uses non-empty strings without trimming for these path fields. All four assertions pass with that fix.

Screenshots, recordings, or supporting files

None attached.

Workaround

No workaround was verified.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedfeature request acceptedbugSomething is broken or behaving incorrectly.via-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions