[Bug]: Windows run-file lifecycle E2E cannot detect private snapshot directories

Open Beginner friendly
#19,286 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, playwright, typescript
Domain
devops, testing

Research direction

Read e2e/specs/mock/run-files-lifecycle.spec.ts, especially snapshotDirectories(), waitForPrivateSnapshot(), and expectSnapshotsRemoved(). Compare its directory filter with the Windows UUID naming in packages/api/src/utils/windowsPrivate.ts and the POSIX branch in packages/api/src/agents/files/snapshots.ts. Update discovery to recognize both naming conventions, then run the lifecycle E2E file on Windows and POSIX; done means both lifecycle scenarios detect creation and verify cleanup.

Written by the indexing model from the issue text.

Description

🐛 bug
What happened?

The run-file snapshot lifecycle E2E tests cannot discover private snapshot directories created on native Windows.

This regression is present at commit b59574c6a65270b08475bd3abaa23d1dcabb312d, following the Windows-specific private-directory implementation introduced by [PR #18863](https://github.com/LibreChat-AI/LibreChat/pull/18863).

Root cause

The Windows implementation creates private snapshot directories through:

[packages/api/src/utils/windowsPrivate.ts](https://github.com/LibreChat-AI/LibreChat/blob/b59574c6a65270b08475bd3abaa23d1dcabb312d/packages/api/src/utils/windowsPrivate.ts#L389-L400)

const directory = win32.join(parent, `${win32.basename(prefix)}${randomUUID()}`);

The resulting directory name has the librechat-run-files- prefix followed by a full UUID, including hyphens.

The production snapshot store selects this implementation on Windows:

[packages/api/src/agents/files/snapshots.ts](https://github.com/LibreChat-AI/LibreChat/blob/b59574c6a65270b08475bd3abaa23d1dcabb312d/packages/api/src/agents/files/snapshots.ts#L88-L98)

const prefix = join(tmpdir(), 'librechat-run-files-');
if (process.platform === 'win32') return makeWindowsPrivateDirectory(prefix);

However, the E2E test's snapshotDirectories() function only accepts directory names with exactly six alphanumeric characters after the prefix:

[e2e/specs/mock/run-files-lifecycle.spec.ts](https://github.com/LibreChat-AI/LibreChat/blob/b59574c6a65270b08475bd3abaa23d1dcabb312d/e2e/specs/mock/run-files-lifecycle.spec.ts#L102-L109)

(entry) => entry.isDirectory() && /^librechat-run-files-[A-Za-z0-9]{6}$/.test(entry.name)

That pattern matches the directory naming convention produced by the POSIX fs.mkdtemp() branch, but not the Windows UUID-based directory name.

Consequences

The waitForPrivateSnapshot() helper polls for exactly one newly created private snapshot directory:

[e2e/specs/mock/run-files-lifecycle.spec.ts](https://github.com/LibreChat-AI/LibreChat/blob/b59574c6a65270b08475bd3abaa23d1dcabb312d/e2e/specs/mock/run-files-lifecycle.spec.ts#L115-L126)

Because the Windows-created directory is filtered out, the helper receives an empty list and the assertion expecting one directory cannot succeed.

This affects the following E2E scenarios:

  1. cancellation deletes private snapshots and a later turn cannot publish their IDs
  2. a checkpoint resume restores publications and requires private outputs to be regenerated

There is an additional consequence: expectSnapshotsRemoved() also uses snapshotDirectories(). Therefore, the same incorrect name filter prevents that helper from reliably observing the Windows snapshot directory when checking cleanup.

Expected behavior

The lifecycle E2E tests must recognize the private snapshot directories created by both platform implementations.

The directory-discovery logic should not assume that every platform generates a six-character alphanumeric suffix. It should use a platform-independent way to identify the directories created by the snapshot store, or correctly account for the actual naming conventions of both implementations.

The tests must continue to verify:

  • creation and discovery of private snapshot directories;
  • cancellation cleanup;
  • checkpoint-resume behavior;
  • removal of private snapshot directories after the corresponding lifecycle operations.

The Windows ACL protection introduced by PR #18863 must remain unchanged. This report concerns the mismatch between the Windows directory naming implementation and the E2E test's directory-discovery logic; it does not claim that the Windows ACL implementation itself is defective.

Repository-wide search at the audited revision

The source tree was searched for:

  • makeWindowsPrivateDirectory;
  • librechat-run-files-;
  • snapshotDirectories;
  • newSnapshotDirectories;
  • waitForPrivateSnapshot;
  • temporary-directory enumeration and name-based filtering.

The search identified one production caller of makeWindowsPrivateDirectory() and one E2E directory-name filter responsible for the mismatch. No additional independent occurrence of the same naming/detection defect was identified in the audited source tree.

Related references

Version Information

Repository: LibreChat-AI/LibreChat

Audited source revision:

b59574c6a65270b08475bd3abaa23d1dcabb312d

Commit subject:

🦗 fix: Explain Why Gemini Stops Without an Answer (#19133)

Commit URL:

https://github.com/LibreChat-AI/LibreChat/commit/b59574c6a65270b08475bd3abaa23d1dcabb312d

Branch: Not specified. The audit is pinned to the exact commit above.

Repository runtime declarations at this revision:

  • Node.js: 24.22.3 (.nvmrc)
  • npm: 11.13.0 (packageManager in root package.json)
  • Playwright: 1.62.1 (resolved in package-lock.json)

Affected environment:

Native Windows, where process.platform === 'win32'.

The POSIX implementation uses fs.mkdtemp(), while the Windows implementation uses makeWindowsPrivateDirectory() and appends a UUID.

The issue concerns native host filesystem behavior and the E2E test infrastructure. WSL or a Linux Docker container does not exercise the Windows-specific production branch.

Application diagnostics: Not applicable. This is a source-level test-infrastructure issue, not a report about a deployed LibreChat instance.

Docker image/build information: No Docker rebuild was used for this source-level audit.

Execution evidence: The issue was established by inspecting the exact source revision. A native Windows Playwright execution against this commit was not performed as part of this audit. No Windows runtime version or captured Windows test log is therefore claimed.

Related issue: #18838 (closed; original Windows private-files security issue associated with PR #18863).

Steps to Reproduce
  1. Check out LibreChat source revision:

    b59574c6a65270b08475bd3abaa23d1dcabb312d

  2. Use a native Windows environment. Do not use WSL or a Linux Docker container for this reproduction.

  3. Use the repository-declared Node.js and npm versions:

    • Node.js 24.22.3
    • npm 11.13.0
  4. Install the repository dependencies using the committed lockfile.

  5. Open a terminal in the repository root.

  6. Run the existing mock E2E script with the lifecycle test file as its argument:

    npm run e2e:mock -- 'e2e/specs/mock/run-files-lifecycle.spec.ts'
    
  7. Inspect the scenario:

    cancellation deletes private snapshots and a later turn cannot publish their IDs

  8. The snapshot store creates a private directory through the Windows-specific makeWindowsPrivateDirectory() implementation.

  9. Inspect snapshotDirectories() in e2e/specs/mock/run-files-lifecycle.spec.ts. Its regular expression only accepts names matching:

    librechat-run-files- followed by exactly six alphanumeric characters.

  10. The Windows-created UUID-based directory does not match that expression. Consequently, the directory is excluded from the returned list.

  11. waitForPrivateSnapshot() polls for one matching directory, but the filtered result remains empty. The expectation .toBe(1) therefore cannot be satisfied.

  12. Inspect the scenario:

    a checkpoint resume restores publications and requires private outputs to be regenerated

    It uses the same discovery helper and is affected by the same mismatch.

  13. Inspect expectSnapshotsRemoved(). It also relies on snapshotDirectories(), so the cleanup check uses the same incompatible name filter.

Expected result

The E2E tests discover the directory created by the Windows snapshot implementation, verify its contents, and correctly verify its removal after cancellation or checkpoint-related lifecycle operations.

The test should pass on Windows and POSIX without weakening the snapshot privacy or cleanup assertions.

What browsers are you seeing the problem on?

No response

Relevant log output
No native Windows runtime log was captured during this source-level audit.

The following excerpts demonstrate the statically verified mismatch. They are source excerpts, not a captured test execution transcript.

**Windows directory generation**

File: `packages/api/src/utils/windowsPrivate.ts`


const directory = win32.join(parent, `${win32.basename(prefix)}${randomUUID()}`);


**E2E directory filter**

File: `e2e/specs/mock/run-files-lifecycle.spec.ts`


(entry) => entry.isDirectory() && /^librechat-run-files-[A-Za-z0-9]{6}$/.test(entry.name)


**E2E expectation**

File: `e2e/specs/mock/run-files-lifecycle.spec.ts`


await expect
  .poll(async () => {
    directories = await newSnapshotDirectories(before);
    return directories.length;
  })
  .toBe(1);


The Windows-generated directory name does not satisfy the regular expression. It is consequently excluded before the directory count is evaluated.

Expected source-level result:

- Windows creates the private directory.
- `snapshotDirectories()` does not include that directory.
- `waitForPrivateSnapshot()` observes zero matching directories instead of one.
- The expectation for one matching directory cannot be satisfied.

No exact Playwright timeout message, Windows exception, or stack trace is presented because a native Windows execution was not performed for this audit.

This evidence identifies a deterministic source-level mismatch between the directory producer and the E2E directory detector.
Screenshots

No response

Code of Conduct
  • I agree to follow this project's Code of Conduct
Dominant language
TypeScript
Stars
45.6k
Forks
9.4k
Avg merge
16h 24m
Merged PRs (30d)
825

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from LibreChat-AI/LibreChat

All issues in LibreChat-AI/LibreChat

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.