Skip to content

Missing x-opencode-session header in API requests #1

Description

@bafplus

Description

The collector.sh script makes requests to the OpenCode GO Zen API without the required x-opencode-session header. Starting 09/06, requests missing this header may error.

Affected endpoints

  • GET /zen/go/v1/models
  • GET /zen/go/v1/usage

Error message from OpenCode GO

Some of your requests to OpenCode Go are missing an x-opencode-session header. If we don't have this we cannot properly optimize our service. Starting 09/06 requests missing this header may error.

Suggested fix

Generate a stable UUID per installation and include it as x-opencode-session header in all curl requests. Example:

SESSION_ID_FILE="${HOME}/.local/share/opencode/go-usage-session-id"
if [[ -f "$SESSION_ID_FILE" ]]; then
  SESSION_ID=$(<"$SESSION_ID_FILE")
else
  SESSION_ID=$(cat /proc/sys/kernel/random/uuid)
  mkdir -p "$(dirname "$SESSION_ID_FILE")"
  printf '%s' "$SESSION_ID" > "$SESSION_ID_FILE"
fi

# Add to curl calls:
curl -H "x-opencode-session: $SESSION_ID" ...

Environment

  • Plugin version: 1.0.0
  • OS: Linux (Arch/Omarchy)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions