hashicorp/nomad · error

AskSecret is not supported in this implementation

Error message

AskSecret is not supported in this implementation

What it means

Returned by HcLogUI.AskSecret: this UI writes to an hclog logger only and has no interactive stdin, so any attempt to prompt for a secret (e.g. from a non-interactive command) is unsupported.

Source

Thrown at helper/logging/logging.go:24

import (
	"fmt"

	"github.com/hashicorp/go-hclog"
)

// HcLogUI is an implementation of Ui that takes a hclogger
// and uses it to Log the output. It is intended for write only
// use cases and the Ask/AskSecret methods are not implemented.
type HcLogUI struct {
	Log hclog.Logger
}

func (l *HcLogUI) Ask(query string) (string, error) {
	return "", fmt.Errorf("Ask is not supported in this implementation")
}

func (l *HcLogUI) AskSecret(query string) (string, error) {
	return "", fmt.Errorf("AskSecret is not supported in this implementation")
}

func (l *HcLogUI) Output(message string) {
	l.Log.Info(message)
}

func (l *HcLogUI) Info(message string) {
	l.Log.Info(message)
}

func (l *HcLogUI) Error(message string) {
	l.Log.Error(message)
}

func (l *HcLogUI) Warn(message string) {
	l.Log.Warn(message)
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Provide secrets via flags, environment variables, or config files instead of prompting.
  2. Swap in an interactive Ui implementation (BasicUi with stdin reader) when a secret prompt is required.
  3. Catch the error and fail fast with guidance on the non-interactive way to supply the secret.

Example fix

// before
secret, err := ui.AskSecret("Token:")
// after
secret := os.Getenv("NOMAD_TOKEN")
if secret == "" {
    return errors.New("NOMAD_TOKEN required in non-interactive mode")
}
Defensive patterns

Strategy: fallback

Validate before calling

if _, ok := ui.(*logging.HcLogUI); ok {
    return errors.New("cannot prompt for secrets with HcLogUI; use env/flag")
}

Type guard

if _, ok := ui.(*logging.HcLogUI); ok {
    // secret prompting unsupported; require explicit secret input
    return nil
}

Try / catch

secret, err := ui.AskSecret("Token:")
if err != nil {
    secret = os.Getenv("MY_TOKEN")
    if secret == "" {
        return err
    }
}

Prevention

When it happens

Trigger: Any code path calling HcLogUI.AskSecret(query) to collect a password/token from the user.

Common situations: Commands prompting for credentials (e.g. ACL bootstrap secrets, Vault tokens) when the CLI was configured with the logging-backed UI instead of an interactive one.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/7fdeff157571ce53. Report an issue: GitHub.