"Failed to execute command" for a few reasons with cryptic errors that hard to debug #1542

Closed
opened 2026-02-16 17:31:27 -05:00 by yindo · 5 comments
Owner

Originally created by @art-shen on GitHub (Aug 30, 2025).

Originally assigned to: @rekram1-node on GitHub.

If command wasn't able to attach some file, it fails with an empty conversation, nothing is started or printed. For a long time through many tries I wasn't able to notice an error notification shown for a short moment.

Failed to execute command: POST
"http://127.0.0.1:61853/session/ses_7059cd4d0ffeVTj7A09Qnc6ISq/co
mmand": 400 Bad Request {"name": "UnknownError"
, "data": {"message": "Error: File not found:
/path/to/app//(.author.login"}}
  1. I think the current behavior of silent failure with only a cryptic message shown is a really bad experience. I propose to improve the failure information and clearly state in the conversation that the command failed to start because of the error. And specify that the specific file mentioned in the command wasn't loaded.

  2. I propose to add support for launching comments even when some mentioned file was not loaded. I think in many cases this would be a desirable behavior, but probably this should be optional.

  3. And finally, the problem itself specific to my case was that OpenCode is trying to interpret parts of the command prompt that it shouldn’t actually interpret in any way. I mean the code blocks and inline code in Markdown.


Example snippet from my command (I'm symlinking the commands from Claude Code):

  1. Run this to show a context to the user:
     `gh pr list --state open --json number,title,headRefName,author,comments,reviews,additions,deletions,isDraft,updatedAt --jq '.[] | "\("#" + (.number | tostring) | .[0:4] + " " * (4 - length))  \(if .isDraft then "📝 " else "✨ " end)\(.title | .[0:80] + " " * (80 - (.[0:80] | length)))  @\(.author.login | .[0:12] + " " * (12 - (.[0:12] | length)))  \(.headRefName | .[0:30] + " " * (30 - (.[0:30] | length)))  💬\(.comments | length)/🧵\((.reviews | length | tostring) + " " * (2 - (.reviews | length | tostring | length)))  +\((.additions | tostring) + " " * (4 - (.additions | tostring | length)))/-\((.deletions | tostring) + " " * (4 - (.deletions | tostring | length)))  \(.updatedAt[0:10])"'`
     Shows: `PR# ✨/📝 Title(80ch) @author branch(30ch) 💬comments/🧵reviews +adds/-dels date`

From this specific case it was trying to interpret @\(.author.login as a file reference!
And the same problem is for the @author on the next line inside the inline code.

Please make opencode to not interpret content inside the backticks. For both triple backticks code blocks and inline code formatting.

Originally created by @art-shen on GitHub (Aug 30, 2025). Originally assigned to: @rekram1-node on GitHub. If command wasn't able to attach some file, it fails with an empty conversation, nothing is started or printed. For a long time through many tries I wasn't able to notice an error notification shown for a short moment. ``` Failed to execute command: POST "http://127.0.0.1:61853/session/ses_7059cd4d0ffeVTj7A09Qnc6ISq/co mmand": 400 Bad Request {"name": "UnknownError" , "data": {"message": "Error: File not found: /path/to/app//(.author.login"}} ``` 1. I think the current behavior of silent failure with only a cryptic message shown is a really bad experience. I propose to improve the failure information and clearly state in the conversation that the command failed to start because of the error. And specify that the specific file mentioned in the command wasn't loaded. 2. I propose to add support for launching comments even when some mentioned file was not loaded. I think in many cases this would be a desirable behavior, but probably this should be optional. 3. And finally, the problem itself specific to my case was that OpenCode is trying to interpret parts of the command prompt that it shouldn’t actually interpret in any way. I mean the code blocks and inline code in Markdown. --- Example snippet from my command (I'm symlinking the commands from Claude Code): ```md 1. Run this to show a context to the user: `gh pr list --state open --json number,title,headRefName,author,comments,reviews,additions,deletions,isDraft,updatedAt --jq '.[] | "\("#" + (.number | tostring) | .[0:4] + " " * (4 - length)) \(if .isDraft then "📝 " else "✨ " end)\(.title | .[0:80] + " " * (80 - (.[0:80] | length))) @\(.author.login | .[0:12] + " " * (12 - (.[0:12] | length))) \(.headRefName | .[0:30] + " " * (30 - (.[0:30] | length))) 💬\(.comments | length)/🧵\((.reviews | length | tostring) + " " * (2 - (.reviews | length | tostring | length))) +\((.additions | tostring) + " " * (4 - (.additions | tostring | length)))/-\((.deletions | tostring) + " " * (4 - (.deletions | tostring | length))) \(.updatedAt[0:10])"'` Shows: `PR# ✨/📝 Title(80ch) @author branch(30ch) 💬comments/🧵reviews +adds/-dels date` ``` From this specific case it was trying to interpret `@\(.author.login` as a file reference! And the same problem is for the `@author` on the next line inside the inline code. Please make opencode to not interpret content inside the backticks. For both triple backticks code blocks and inline code formatting.
yindo closed this issue 2026-02-16 17:31:27 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 30, 2025):

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

  • #2198: OpenCode's file reference regex is too inclusive and doesn't account for context, causing it to incorrectly interpret content inside backticks and code blocks as file references

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Aug 30, 2025): This issue might be a duplicate of existing issues. Please check: - #2198: OpenCode's file reference regex is too inclusive and doesn't account for context, causing it to incorrectly interpret content inside backticks and code blocks as file references Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Aug 30, 2025):

the backticks thing is going to get fixed v soon things for raising, as for expected behavior when a file doesnt exist, do you think it would be better to let command go through but then toast for a file that doesnt exist?

So if I do:

@non-existant

instead of seeing Failed Command, Id see the command actually go through but then an error toast saying it failed to read a particular file?

@rekram1-node commented on GitHub (Aug 30, 2025): the backticks thing is going to get fixed v soon things for raising, as for expected behavior when a file doesnt exist, do you think it would be better to let command go through but then toast for a file that doesnt exist? So if I do: @non-existant instead of seeing Failed Command, Id see the command actually go through but then an error toast saying it failed to read a particular file?
Author
Owner

@rekram1-node commented on GitHub (Aug 30, 2025):

what do you think?

@rekram1-node commented on GitHub (Aug 30, 2025): what do you think?
Author
Owner

@art-shen commented on GitHub (Aug 30, 2025):

If the behavior is clear for the user (explicitly shown that the command wasn't able to load some files), I guess it's more practical and convenient for the command to still go through.

I can imagine some cases when there is no sense for a command to even try to work if it wasn't able to load the files. But if it's clear immediately that files weren’t loaded, I don't think it is a critical problem or something. User would be able to act on it and resolve it if it is important.

@art-shen commented on GitHub (Aug 30, 2025): If the behavior is clear for the user (explicitly shown that the command wasn't able to load some files), I guess it's more practical and convenient for the command to still go through. I can imagine some cases when there is no sense for a command to even try to work if it wasn't able to load the files. But if it's clear immediately that files weren’t loaded, I don't think it is a critical problem or something. User would be able to act on it and resolve it if it is important.
Author
Owner

@rekram1-node commented on GitHub (Sep 2, 2025):

should be fixed in next release

@rekram1-node commented on GitHub (Sep 2, 2025): should be fixed in next release
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1542