Skip to content

File Upload: Full path is being passed as the document name to the AP #36113

Closed as not planned

Description

@laflamablanc

Description

Uploaded a PDF named SOP.pdf to OpenCode and got the following error:

undefined: The document file name can only contain alphanumeric characters, whitespace characters, hyphens, parentheses, and square brackets. The name can't contain more than one consecutive whitespace character. Check that the file name conforms to these restrictions and retry your request.

It appears that the full file path "/User/laflamablanc/Downloads/SOP.pdf" is being passed as the filename and throwing an error

The Bedrock/Anthropic API is sending back the error that this is an invalid name.

Request: Clean up the filepath and only send the filename to the API

Plugins

No response

OpenCode version

1.17.17

Steps to reproduce

  1. Upload any file by dragging into the chat window
  2. Receive error about invalid filename

Screenshot and/or share link

Image

Operating System

macOS 26.5.2

Terminal

No response

Activity

  1. github-actions commented on Jul 9, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of an existing issue. Please check:

  2. laflamablanc commented on Jul 9, 2026

    @laflamablanc
    Author

    The issue is in packages/opencode/src/session/prompt.ts — when a file is attached, the filename field is set to whatever path string was used

    This gets passed through message-v2.ts into the AI SDK's convertToModelMessages(), which then sends it to the Anthropic/Bedrock API as the document name. The API rejects filenames containing / characters.

    The fix would be a one-liner in prompt.ts to use path.basename(filename) instead of the full path when setting the filename field on file parts.

  3. joaomj commented on Jul 15, 2026

    @joaomj

    i am facing the same issue with bedrock.

    Version   1.18.1 (latest)
    Date      2026-07-15T12:38:27.653Z
    OS        Linux 6.8.0-134-generic (arm64)
    Terminal  xterm-256color
    Session IDses_09a3a6cf0ffegoP0YYJYWqmQti
    Model     amazon-bedrock/us.anthropic.claude-opus-4-8
    
  4. github-actions commented on Sep 14, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions