Skip to content

[FEATURE]: Add environment variable validation to opencode GitHub Action #57340

Closed

Description

@abdelaziz11

[FEATURE]: Add environment variable validation to opencode GitHub Action

  • I have verified this is not a duplicate

Description

The opencode GitHub Action should validate that required environment variables are properly set before running. Currently, if OPENCODE_API_KEY is missing or malformed, the action silently fails.

Proposed Solution

Add a validation step at the beginning of the action that:

  1. Checks if OPENCODE_API_KEY is set and non-empty
  2. Validates the key format (should start with a known prefix)
  3. Tests connectivity to api.opencode.ai with the key
  4. Reports the validation result in the issue comment for debugging

Something like:

- name: Validate environment
  run: |
    if [ -z "$OPENCODE_API_KEY" ]; then
      gh issue comment ${{ github.event.issue.number }} --body "❌ OPENCODE_API_KEY is not set"
      exit 1
    fi
    # Report key metadata (not the key itself!) for debugging
    KEY_LEN=${#OPENCODE_API_KEY}
    KEY_PREFIX="${OPENCODE_API_KEY:0:8}"
    gh issue comment ${{ github.event.issue.number }} --body "✅ Environment validated: key_length=$KEY_LEN, prefix=$KEY_PREFIX..."

Why This Is Needed

In production CI/CD pipelines, silent failures waste developer time. A validation step would catch configuration issues immediately.

Alternatives Considered

  • Manually adding validation to each workflow (too much boilerplate)
  • Using a separate validation action (adds complexity)

Activity

  1. opencode-agent commented on Oct 20, 2026

    @opencode-agent
    Contributor

    Thanks for the suggestion. The request is for the opencode GitHub Action to check up front that OPENCODE_API_KEY is set, and to fail with a clear error instead of failing silently. Maintainers will consider it.

    One note on the snippet: we wouldn't post anything derived from the key, including its length or prefix, in an issue comment. Issue comments are public, and even part of a secret shouldn't be exposed. Any validation would report only whether the key is present or valid, in the workflow log.

    Related: #57337, #57339.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions