Skip to content

[Bug]: File paths with square brackets (e.g. Next.js dynamic routes) fail to open #2917

@paulo20223

Description

@paulo20223

Bug Report

Description

Forge fails to open files whose paths contain square brackets ([ and ]). This is a common pattern in Next.js projects that use dynamic routes (e.g. [locale], [id], [slug]).

Steps to Reproduce

  1. Have a Next.js project with a dynamic route layout file, e.g.:
    src/app/[locale]/layout.tsx
    
  2. Reference the file in conversation or let Forge attempt to read it.

Expected Behavior

The file should be opened and read successfully, as the square brackets are literal characters in the filesystem path.

Actual Behavior

Forge produces the following error:

ERROR: Failed to open file .../src/app/[locale

Caused by:
    No such file or directory (os error 2)

The path is truncated at the [ character — everything from [locale] onward (including ]/layout.tsx) is stripped or lost, resulting in an invalid path.

Impact

This affects any project using:

  • Next.js App Router dynamic routes ([param], [...catchAll], [[...optional]])
  • Any framework or convention that uses square brackets in directory/file names

Since Next.js App Router is one of the most popular frontend frameworks, this is a significant usability issue.

Environment

  • macOS
  • Forge CLI (latest as of 2025-04-10)

Metadata

Metadata

Labels

severity: highSignificant impact; core functionality is impaired.type: bugSomething isn't working.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions