{"record":{"id":"b3a08323d371878c","repo":"txthinking/brook","slug":"invalid-type","errorCode":null,"errorMessage":"invalid type","messagePattern":"invalid type","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/brook/main.go","lineNumber":1985,"sourceCode":"\t\t\t\t\tName:  \"short\",\n\t\t\t\t\tUsage: \"Short for A/AAAA\",\n\t\t\t\t},\n\t\t\t\t&cli.BoolFlag{\n\t\t\t\t\tName:  \"example\",\n\t\t\t\t\tUsage: \"Show a minimal example of usage\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\tif c.Bool(\"example\") {\n\t\t\t\t\tfmt.Println(\"brook dnsclient --domain google.com\")\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tif c.String(\"domain\") == \"\" {\n\t\t\t\t\treturn cli.ShowSubcommandHelp(c)\n\t\t\t\t}\n\t\t\t\tt, ok := dns.StringToType[c.String(\"type\")]\n\t\t\t\tif !ok {\n\t\t\t\t\treturn errors.New(\"invalid type\")\n\t\t\t\t}\n\t\t\t\tdc := &brook.DNSClient{Server: c.String(\"dns\")}\n\t\t\t\tm := &dns.Msg{}\n\t\t\t\tm.SetQuestion(strings.TrimRight(c.String(\"domain\"), \".\")+\".\", t)\n\t\t\t\tm, err := dc.Exchange(m)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"short\") && (c.String(\"type\") == \"A\" || c.String(\"type\") == \"AAAA\") {\n\t\t\t\t\tfor _, v := range m.Answer {\n\t\t\t\t\t\tif t, ok := v.(*dns.A); ok {\n\t\t\t\t\t\t\tfmt.Println(t.A)\n\t\t\t\t\t\t\treturn nil\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif t, ok := v.(*dns.AAAA); ok {\n\t\t\t\t\t\t\tfmt.Println(t.AAAA)\n\t\t\t\t\t\t\treturn nil\n\t\t\t\t\t\t}","sourceCodeStart":1967,"sourceCodeEnd":2003,"githubUrl":"https://github.com/txthinking/brook/blob/5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8/cli/brook/main.go#L1967-L2003","documentation":"The `brook dns` subcommand looks up c.String(\"type\") in the miekg/dns StringToType map to convert the record-type flag into a dns.Type constant. If the string is not a recognized DNS record type (e.g. not A, AAAA, CNAME, TXT, MX...), brook throws \"invalid type\" before issuing the query.","triggerScenarios":"Running `brook dns --domain example.com --type a` (lowercase, not in dns.StringToType) or `--type A-RECORD` or any misspelled type at cli/brook/main.go:1985.","commonSituations":"Using lowercase type names like `a` or `cname`; using pseudo-type names like ANY/AXFR that the map may not contain in that form; scripting with a variable that is empty so --type resolves to \"\".","solutions":["Use the exact uppercase mnemonics: --type A, AAAA, CNAME, MX, TXT, NS, SRV, PTR, SOA","Omit --type entirely if a default (A) is acceptable, per subcommand help","Print valid types via the dns library's TypeToString conventions to pick a correct value"],"exampleFix":"// before\nbrook dns --dns 8.8.8.8:53 --domain example.com --type a\n// after\nbrook dns --dns 8.8.8.8:53 --domain example.com --type A","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default --type to A when unset or unrecognized"],"tags":["cli","dns","validation","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8","analyzedAt":"2026-09-06T04:35:00.432Z","contentChangedAt":"2026-09-06T04:35:00.432Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}