{"record":{"id":"7fdeff157571ce53","repo":"hashicorp/nomad","slug":"asksecret-is-not-supported-in-this-implementation","errorCode":null,"errorMessage":"AskSecret is not supported in this implementation","messagePattern":"AskSecret is not supported in this implementation","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/logging/logging.go","lineNumber":24,"sourceCode":"import (\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\nfunc (l *HcLogUI) Warn(message string) {\n\tl.Log.Warn(message)\n}\n","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/logging/logging.go#L6-L42","documentation":"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.","triggerScenarios":"Any code path calling HcLogUI.AskSecret(query) to collect a password/token from the user.","commonSituations":"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.","solutions":["Provide secrets via flags, environment variables, or config files instead of prompting.","Swap in an interactive Ui implementation (BasicUi with stdin reader) when a secret prompt is required.","Catch the error and fail fast with guidance on the non-interactive way to supply the secret."],"exampleFix":"// before\nsecret, err := ui.AskSecret(\"Token:\")\n// after\nsecret := os.Getenv(\"NOMAD_TOKEN\")\nif secret == \"\" {\n    return errors.New(\"NOMAD_TOKEN required in non-interactive mode\")\n}","handlingStrategy":"fallback","validationCode":"if _, ok := ui.(*logging.HcLogUI); ok {\n    return errors.New(\"cannot prompt for secrets with HcLogUI; use env/flag\")\n}","typeGuard":"if _, ok := ui.(*logging.HcLogUI); ok {\n    // secret prompting unsupported; require explicit secret input\n    return nil\n}","tryCatchPattern":"secret, err := ui.AskSecret(\"Token:\")\nif err != nil {\n    secret = os.Getenv(\"MY_TOKEN\")\n    if secret == \"\" {\n        return err\n    }\n}","preventionTips":["Never use HcLogUI for commands that collect credentials","Provide secrets via environment variables or files","Fail fast with a clear message instead of prompting in CI"],"tags":["ui","non-interactive","secrets","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"}