hashicorp/nomad · error

Ask is not supported in this implementation

Error message

Ask is not supported in this implementation

What it means

HcLogUI is a go-ui.Ui implementation backed only by an hclog.Logger. Interactive input is impossible through a logger, so Ask always returns this error. It exists so HcLogUI satisfies the Ui interface for non-interactive use cases.

Source

Thrown at helper/logging/logging.go:20

// SPDX-License-Identifier: BUSL-1.1

package logging

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)
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Do not call Ask on HcLogUI; restructure the caller to use flags/arguments or defaults instead of prompting.
  2. Use a different Ui implementation (e.g. BasicUi with a reader) when interactive input is required.
  3. Catch the error and fall back to a sensible default value for the query.

Example fix

// before
answer, err := ui.Ask("Proceed? (y/n)")
// after
if proceedFlag == "" {
    return errors.New("-proceed is required in non-interactive mode")
}
answer := proceedFlag
Defensive patterns

Strategy: fallback

Validate before calling

if _, ok := ui.(*logging.HcLogUI); ok && needsInput {
    return errors.New("interactive input unavailable; pass a flag or env var instead")
}

Type guard

if h, ok := ui.(*logging.HcLogUI); ok {
    // non-interactive UI: never call h.Ask
    _ = h
}

Try / catch

answer, err := ui.Ask("Proceed?")
if err != nil {
    // HcLogUI.Ask always errors; use default
    answer = defaultAnswer
}

Prevention

When it happens

Trigger: Any code path that calls HcLogUI.Ask(query) to prompt the user for input, e.g. a CLI command requesting confirmation or a value.

Common situations: Running a command in non-interactive environments (CI, agents, systemd) where the implementation was wired with HcLogUI but a code path still tries to prompt; usually indicates the command should have detected non-interactivity first.

Related errors


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