{"record":{"id":"039658639aacd499","repo":"tsenart/vegeta","slug":"encode-unknown-encoding-q","errorCode":null,"errorMessage":"encode: unknown encoding %q","messagePattern":"encode: unknown encoding %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"encode.go","lineNumber":97,"sourceCode":"\t\treturn err\n\t}\n\n\tout, err := file(output, true)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer out.Close()\n\n\tvar enc vegeta.Encoder\n\tswitch to {\n\tcase encodingCSV:\n\t\tenc = vegeta.NewCSVEncoder(out)\n\tcase encodingGob:\n\t\tenc = vegeta.NewEncoder(out)\n\tcase encodingJSON:\n\t\tenc = vegeta.NewJSONEncoder(out)\n\tdefault:\n\t\treturn fmt.Errorf(\"encode: unknown encoding %q\", to)\n\t}\n\n\tsigch := make(chan os.Signal, 1)\n\tsignal.Notify(sigch, os.Interrupt)\n\n\tfor {\n\t\tselect {\n\t\tcase <-sigch:\n\t\t\treturn nil\n\t\tdefault:\n\t\t}\n\n\t\tvar r vegeta.Result\n\t\tif err = dec.Decode(&r); err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn err","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/encode.go#L79-L115","documentation":"`vegeta encode` writes results in the encoding chosen by the -to flag; only gob, csv, and json are recognized. An unknown -to value reaches the default branch and returns this error naming the bad encoding.","triggerScenarios":"`vegeta encode -to=<unsupported>`, e.g. `-to=yaml`, `-to=`, or a typo like `-to=jso n` / `-to=JSON` if matching is case-sensitive in the caller's flags.","commonSituations":"Users assuming arbitrary encodings are supported; shell variables with empty or mis-typed encoding values; legacy scripts using formats from other tools.","solutions":["Use one of the supported values for -to: gob, csv, or json.","Check `vegeta encode -help` for the exact accepted encoding strings in your version.","Quote/trim the shell variable feeding -to so it contains exactly the encoding name."],"exampleFix":"// before\nvegeta encode -to=yaml < results.gob\n// after\nvegeta encode -to=json < results.gob","handlingStrategy":"validation","validationCode":"var validEncodings = map[string]bool{\"gob\": true, \"csv\": true, \"json\": true}\nif !validEncodings[to] {\n    return fmt.Errorf(\"-to %q invalid; use gob, csv or json\", to)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only gob, csv, json for -to.","Trim/validate shell variables before interpolating into CLI flags.","Check `vegeta encode -help` after upgrades for accepted values."],"tags":["cli","configuration","validation","unsupported-format"],"backgroundTag":"unsupported-format-value","analyzedSha":"cf5811269046c672a604b1eb352204d30f16ae4a","analyzedAt":"2026-08-31T11:04:20.464Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}