file substitution in configuration results in "invalid JSON" #999

Closed
opened 2026-02-16 17:29:03 -05:00 by yindo · 1 comment
Owner

Originally created by @muni-corn on GitHub (Jul 30, 2025).

configuration file

using Nix as my configuration tool of choice, my setup (opencode.nix results in this config.json:

{
  "$schema": "https://opencode.ai/config.json",
  "autoupdate": false,
  "mcp": {
    // ...
    "github": {
      "enabled": true,
      "headers": {
        "Authorization": "Bearer {file:/home/muni/.config/sops-nix/secrets/github_pat}"
      },
      "type": "remote",
      "url": "https://api.githubcopilot.com/mcp/"
    },
    // ...
  }
}

observed behavior

when i run opencode, i get:

Error: Config file at /home/muni/.config/opencode/config.json is not valid JSON

if i remove the headers object, opencode can start as expected again, without error.

expected behavior

i expect opencode to substitute the contents of my file into the Authorization header, as documented here: https://opencode.ai/docs/config/#files

i assume it works with remote mcp configurations too, at least 😅 https://opencode.ai/docs/mcp-servers/#remote

opencode version

i just upgraded to opencode 0.3.85, but this issue has been present since 0.3.80 as well.

other notes

the github_pat file has a permissions mode of 400. it is not a symlink.

Originally created by @muni-corn on GitHub (Jul 30, 2025). ## configuration file using Nix as my configuration tool of choice, my setup ([opencode.nix](https://github.com/muni-corn/dotfiles/blob/e0e4663bc663093e2c3059d0ce78fee64af858e7/muni/ai/opencode.nix) results in this config.json: ```jsonc { "$schema": "https://opencode.ai/config.json", "autoupdate": false, "mcp": { // ... "github": { "enabled": true, "headers": { "Authorization": "Bearer {file:/home/muni/.config/sops-nix/secrets/github_pat}" }, "type": "remote", "url": "https://api.githubcopilot.com/mcp/" }, // ... } } ``` ## observed behavior when i run opencode, i get: ```log Error: Config file at /home/muni/.config/opencode/config.json is not valid JSON ``` if i remove the `headers` object, `opencode` can start as expected again, without error. ## expected behavior i expect opencode to substitute the contents of my file into the `Authorization` header, as documented here: https://opencode.ai/docs/config/#files i assume it works with remote mcp configurations too, at least 😅 https://opencode.ai/docs/mcp-servers/#remote ## opencode version i just upgraded to `opencode 0.3.85`, but this issue has been present since `0.3.80` as well. ## other notes the `github_pat` file has a permissions mode of `400`. it is not a symlink.
yindo closed this issue 2026-02-16 17:29:03 -05:00
Author
Owner

@rekram1-node commented on GitHub (Jul 31, 2025):

I will have a fix up for this later tonight, thanks for calling it out

@rekram1-node commented on GitHub (Jul 31, 2025): I will have a fix up for this later tonight, thanks for calling it out
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#999