Skip to content

ENAMETOOLONG Crash during text input parsing #26979

@betterversion

Description

@betterversion

Description

The CLI crashes when pasting long technical text containing slashes or version numbers (e.g., package@14). It appears the input parser mistakenly identifies long strings of prose as local file paths and passes them to lstat.

Root Cause

Inadequate validation/sanitization of extracted "potential paths" before system calls. If the extracted string exceeds OS PATH_MAX or contains invalid characters (like quotes/newlines), the process exits with an unhandled ENAMETOOLONG error. This is likely due to a greedy regex (e.g., \/[^\s]+) used for path discovery in user input.

Reproduction

Paste a 300+ character paragraph containing a directory-like string (e.g., /my-repo/) followed by a long block of text without spaces.

Example Trigger

The crash was triggered by the following string:
.../my-bootstrap-scripts/14", restart_service....

Expected Behavior

The CLI should fail gracefully if a potential path is invalid or too long, instead of crashing with a stack trace.

Environment

  • OS: darwin (macOS)
  • Version: 0.41.2 (as identified from system paths)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/coreIssues related to User Interface, OS Support, Core Functionalitystatus/need-triageIssues that need to be triaged by the triage automation.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions