{"record":{"id":"9f95c79f84b993eb","repo":"hashicorp/nomad","slug":"writer-ui-unsupported-ui-type-t","errorCode":null,"errorMessage":"writer ui: unsupported Ui type: %T","messagePattern":"writer ui: unsupported Ui type: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/ui/writer_ui.go","lineNumber":62,"sourceCode":"\t\t}\n\n\t\tswitch u := ui.(type) {\n\t\tcase *cli.MockUi:\n\t\t\twUI.reader = u.InputReader\n\t\t\twUI.writer = u.OutputWriter\n\t\t\twUI.errorWriter = u.ErrorWriter\n\t\t\twUI.baseUi = u\n\t\t\tdone = true\n\t\tcase *cli.BasicUi:\n\t\t\twUI.reader = u.Reader\n\t\t\twUI.writer = u.Writer\n\t\t\twUI.errorWriter = u.ErrorWriter\n\t\t\twUI.baseUi = u\n\t\t\tdone = true\n\t\tcase *cli.ColoredUi:\n\t\t\tui = u.Ui\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"writer ui: unsupported Ui type: %T\", ui)\n\t\t}\n\t}\n\n\tif !done {\n\t\treturn nil, errors.New(\"failed to generate command UI\")\n\t}\n\n\treturn &wUI, nil\n}\n\nfunc (w *WriterUI) InputReader() io.Reader  { return w.reader }\nfunc (w *WriterUI) OutputWriter() io.Writer { return w.writer }\nfunc (w *WriterUI) ErrorWriter() io.Writer  { return w.errorWriter }\n\nfunc (w *WriterUI) Output(message string) { w.Ui.Output(message) }\nfunc (w *WriterUI) Info(message string)   { w.Ui.Info(message) }\nfunc (w *WriterUI) Warn(message string)   { w.Ui.Warn(message) }\nfunc (w *WriterUI) Error(message string)  { w.Ui.Error(message) }","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/ui/writer_ui.go#L44-L80","documentation":"NewWriterUI wraps an existing mitchellh/cli.Ui so command output can be redirected to custom writers. It only understands *cli.BasicUi and *cli.ColoredUi; anything else falls into the type-switch default and this error is returned. It exists to fail fast when an unsupported Ui implementation is passed instead of silently mis-routing output.","triggerScenarios":"Calling NewWriterUI with a Ui that is neither *cli.BasicUi nor *cli.ColoredUi — e.g. a custom cli.Ui implementation, a wrapped/proxy Ui type, or a typed nil interface. The test TestWriterUI_AskSecret covers the supported path; any third-party Ui hits the default branch.","commonSituations":"Embedding the library in a TUI or test harness that supplies its own cli.Ui implementation; passing a Ui wrapped in another struct; refactors that changed the concrete Ui type previously passed (e.g. ColoredUi replaced with a custom type).","solutions":["Pass a *cli.BasicUi or *cli.ColoredUi to NewWriterUI (wrap your custom Ui's Writer/Reader/ErrorWriter fields into a *cli.BasicUi instead)","If you own a custom Ui type, extend the type switch in writer_ui.go to handle it, mapping its writer fields onto the WriterUI struct","Check that you are not passing a typed-nil or incorrectly typed interface value; print %T of the argument to confirm its concrete type"],"exampleFix":"// before\nwUI, err := NewWriterUI(&myCustomUi{w: os.Stdout})\n// after\nwUI, err := NewWriterUI(&cli.BasicUi{Writer: os.Stdout, ErrorWriter: os.Stderr, Reader: os.Stdin})","handlingStrategy":"type-guard","validationCode":"func isSupportedUI(u cli.Ui) bool {\n\tswitch u.(type) {\n\tcase *cli.BasicUi, *cli.ColoredUi:\n\t\treturn true\n\t}\n\treturn false\n}\n// call site:\nif !isSupportedUI(myUi) { /* wrap into *cli.BasicUi first */ }","typeGuard":"func asBasicUi(u cli.Ui) (*cli.BasicUi, bool) {\n\tif bu, ok := u.(*cli.BasicUi); ok { return bu, true }\n\tif cu, ok := u.(*cli.ColoredUi); ok {\n\t\treturn &cli.BasicUi{Reader: cu.Reader, Writer: cu.Writer, ErrorWriter: cu.ErrorWriter}, true\n\t}\n\treturn nil, false\n}","tryCatchPattern":null,"preventionTips":["Always construct the Ui as *cli.BasicUi or *cli.ColoredUi before passing to NewWriterUI","Never wrap cli.Ui implementations in custom structs when handing them to this API","Log %T of the Ui argument during integration debugging","Check for typed-nil interfaces: a nil *myUi stored in a cli.Ui is non-nil interface but fails every case"],"tags":["cli","unsupported-type","type-assertion"],"backgroundTag":"unsupported-ui-type","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"}