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
DetachedEnvVarValidator incorrectly rejects optional secret env vars when not provided #5688
When installing a registry MCP server via the API (e.g. from ToolHive Studio) that has optional secret environment variables (like oci-registry's OCI_TOKEN or context7's CONTEXT7_API_KEY), the daemon rejects the workload creation with:
failed to build run config: failed to validate environment variables: missing required secret environment variable: OCI_TOKEN
Both variables are defined in the registry with required: false, secret: true. The registry API correctly returns them that way. The error is wrong.
Root cause
DetachedEnvVarValidator.Validate in pkg/runner/env.go has an else if envVar.Secret branch that fires unconditionally for any unset secret env var, without checking envVar.Required:
CLIEnvVarValidator.Validate handles this correctly — it only enforces envVar.Required and silently skips unset optional secrets. The two validators diverged.
Fix
Remove the else if envVar.Secret branch from DetachedEnvVarValidator.Validate:
} elseifenvVar.Required {
returnnil, fmt.Errorf("missing required environment variable: %s", envVar.Name)
} elseifenvVar.Default!="" {
addAsEnvironmentVariable(envVar, envVar.Default, &suppliedEnvVars)
}
// optional secrets with no value and no default: skip silently
Affected versions
Confirmed present in v0.31.0 and current main.
Steps to reproduce
Open ToolHive Studio and install oci-registry or context7 from the registry
Leave OCI_TOKEN / CONTEXT7_API_KEY blank (they are optional)
Submit — the server fails to start with the error above
Correction to the original report: after tracing through the git history of both the CLI and the catalog, the bug has been present since day one and is not specific to v0.31.0. The else if envVar.Secret branch in DetachedEnvVarValidator has never been correct, and the catalog has had isSecret: true on these env vars from their first commit. There is no code change that activated this at a particular version — it was always broken for any registry server with an optional secret env var left blank.
Further correction to narrow down the trigger: the broken branch in DetachedEnvVarValidator is only reachable when metadata != nil. Before the registry-aware workload creation change (commit 829c4bd, April 21, 2026), Studio sent fully-resolved requests (image URL + env vars already extracted client-side), so metadata was nil in Validate() and the loop never ran. Once Studio started sending {registry: "default", server: "oci-registry"} and letting the daemon resolve metadata server-side, metadata became non-nil and the bug surfaced for any server with an optional secret env var left blank.
Activity
danbarr commentedon Jun 30, 2026
Correction to the original report: after tracing through the git history of both the CLI and the catalog, the bug has been present since day one and is not specific to v0.31.0. The
else if envVar.Secretbranch inDetachedEnvVarValidatorhas never been correct, and the catalog has hadisSecret: trueon these env vars from their first commit. There is no code change that activated this at a particular version — it was always broken for any registry server with an optional secret env var left blank.danbarr commentedon Jun 30, 2026
Further correction to narrow down the trigger: the broken branch in
DetachedEnvVarValidatoris only reachable whenmetadata != nil. Before the registry-aware workload creation change (commit 829c4bd, April 21, 2026), Studio sent fully-resolved requests (image URL + env vars already extracted client-side), sometadatawasnilinValidate()and the loop never ran. Once Studio started sending{registry: "default", server: "oci-registry"}and letting the daemon resolve metadata server-side,metadatabecame non-nil and the bug surfaced for any server with an optional secret env var left blank.Fix DetachedEnvVarValidator rejecting optional secret env vars (stack…