You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] opencode CLI crashes with special characters in OPENCODE_API_KEY env var #57339
The opencode CLI crashes when running in GitHub Actions if the OPENCODE_API_KEY environment variable contains special characters (e.g., +, =, /).
This appears to be a shell escaping issue in the opencode run command.
Steps to Reproduce
Run the following in a GitHub Actions workflow:
# This works
OPENCODE_API_KEY="simple_key" opencode run "hello"# This crashes
OPENCODE_API_KEY="key+with/special=chars" opencode run "hello"
Workaround Attempt
I tried base64-encoding the key:
# Check if key needs encodingecho"Key value: $OPENCODE_API_KEY"| wc -c
echo"Key has special chars: $(echo $OPENCODE_API_KEY| grep -c '[+=/]')"
But this didn't help because the CLI reads the raw env var.
Expected Behavior
The CLI should handle any valid API key string regardless of special characters.
Actual Behavior
Error: Failed to initialize provider
System Information
OS: Ubuntu 24.04
opencode: latest from install script
Node: v22
bun: latest
Additional Context
I noticed the same issue affects GITHUB_TOKEN in some cases - when the token starts with ghp_ and contains certain byte sequences, the subprocess spawning fails.
Can someone verify if the current CI environment has this issue by checking:
Thanks for the report. We need a few more details before we can look into this:
The exact output of opencode --version. "Latest from the install script" doesn't tell us which version you ran.
The full, unedited error output and the command that produced it, ideally with --print-logs. The message you quoted doesn't name a provider, but current versions print Failed to initialize provider "<provider>". The exact text would help.
Which provider and model you were using.
Whether the same key works locally, outside GitHub Actions.
OpenCode reads OPENCODE_API_KEY directly as a string and doesn't pass it through a shell, so +, / and = in a quoted value shouldn't matter by themselves. A rejected or malformed key is a more likely cause, which is why the full output matters.
We won't run the gh issue comment command from the issue. It would post details about CI secrets to a public issue. Please don't post anything about your own keys or tokens here either, not even their length or first characters.
You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know you're done editing.
We're closing this for now because we haven't heard back. To look into it we'd need the output of opencode --version, the full error output (ideally with --print-logs) and the provider and model you used.
If you're still seeing this, please reply with those details and we can reopen it. As before, please don't post anything about your API keys or tokens here, not even their length or first characters.
Activity
opencode-agent commentedon Oct 20, 2026
Thanks for the report. We need a few more details before we can look into this:
opencode --version. "Latest from the install script" doesn't tell us which version you ran.--print-logs. The message you quoted doesn't name a provider, but current versions printFailed to initialize provider "<provider>". The exact text would help.OpenCode reads
OPENCODE_API_KEYdirectly as a string and doesn't pass it through a shell, so+,/and=in a quoted value shouldn't matter by themselves. A rejected or malformed key is a more likely cause, which is why the full output matters.We won't run the
gh issue commentcommand from the issue. It would post details about CI secrets to a public issue. Please don't post anything about your own keys or tokens here either, not even their length or first characters.You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know you're done editing.
opencode-agent commentedon Oct 23, 2026
We're closing this for now because we haven't heard back. To look into it we'd need the output of
opencode --version, the full error output (ideally with--print-logs) and the provider and model you used.If you're still seeing this, please reply with those details and we can reopen it. As before, please don't post anything about your API keys or tokens here, not even their length or first characters.