{"record":{"id":"2d13469f33146e54","repo":"hashicorp/nomad","slug":"ask-is-not-supported-in-this-implementation","errorCode":null,"errorMessage":"Ask is not supported in this implementation","messagePattern":"Ask is not supported in this implementation","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/logging/logging.go","lineNumber":20,"sourceCode":"// SPDX-License-Identifier: BUSL-1.1\n\npackage logging\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/hashicorp/go-hclog\"\n)\n\n// HcLogUI is an implementation of Ui that takes a hclogger\n// and uses it to Log the output. It is intended for write only\n// use cases and the Ask/AskSecret methods are not implemented.\ntype HcLogUI struct {\n\tLog hclog.Logger\n}\n\nfunc (l *HcLogUI) Ask(query string) (string, error) {\n\treturn \"\", fmt.Errorf(\"Ask is not supported in this implementation\")\n}\n\nfunc (l *HcLogUI) AskSecret(query string) (string, error) {\n\treturn \"\", fmt.Errorf(\"AskSecret is not supported in this implementation\")\n}\n\nfunc (l *HcLogUI) Output(message string) {\n\tl.Log.Info(message)\n}\n\nfunc (l *HcLogUI) Info(message string) {\n\tl.Log.Info(message)\n}\n\nfunc (l *HcLogUI) Error(message string) {\n\tl.Log.Error(message)\n}\n","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/logging/logging.go#L2-L38","documentation":"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.","triggerScenarios":"Any code path that calls HcLogUI.Ask(query) to prompt the user for input, e.g. a CLI command requesting confirmation or a value.","commonSituations":"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.","solutions":["Do not call Ask on HcLogUI; restructure the caller to use flags/arguments or defaults instead of prompting.","Use a different Ui implementation (e.g. BasicUi with a reader) when interactive input is required.","Catch the error and fall back to a sensible default value for the query."],"exampleFix":"// before\nanswer, err := ui.Ask(\"Proceed? (y/n)\")\n// after\nif proceedFlag == \"\" {\n    return errors.New(\"-proceed is required in non-interactive mode\")\n}\nanswer := proceedFlag","handlingStrategy":"fallback","validationCode":"if _, ok := ui.(*logging.HcLogUI); ok && needsInput {\n    return errors.New(\"interactive input unavailable; pass a flag or env var instead\")\n}","typeGuard":"if h, ok := ui.(*logging.HcLogUI); ok {\n    // non-interactive UI: never call h.Ask\n    _ = h\n}","tryCatchPattern":"answer, err := ui.Ask(\"Proceed?\")\nif err != nil {\n    // HcLogUI.Ask always errors; use default\n    answer = defaultAnswer\n}","preventionTips":["Detect non-interactive environments before prompting","Design commands to require flags/env vars instead of Ask","Document that HcLogUI is output-only"],"tags":["ui","non-interactive","go"],"backgroundTag":"operation-not-supported","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}