{"record":{"id":"681f253dc738cc14","repo":"tsenart/vegeta","slug":"format-q-isn-t-one-of-s","errorCode":null,"errorMessage":"format %q isn't one of [%s]","messagePattern":"format %q isn't one of \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"attack.go","lineNumber":165,"sourceCode":"\t\tif body, err = io.ReadAll(bodyf); err != nil {\n\t\t\treturn fmt.Errorf(\"error reading %s: %s\", opts.bodyf, err)\n\t\t}\n\t}\n\n\tvar (\n\t\ttr       vegeta.Targeter\n\t\tsrc      = files[opts.targetsf]\n\t\thdr      = opts.headers.Header\n\t\tproxyHdr = opts.proxyHeaders.Header\n\t)\n\n\tswitch opts.format {\n\tcase vegeta.JSONTargetFormat:\n\t\ttr = vegeta.NewJSONTargeter(src, body, hdr)\n\tcase vegeta.HTTPTargetFormat:\n\t\ttr = vegeta.NewHTTPTargeter(src, body, hdr)\n\tdefault:\n\t\treturn fmt.Errorf(\"format %q isn't one of [%s]\",\n\t\t\topts.format, strings.Join(vegeta.TargetFormats, \", \"))\n\t}\n\n\tif !opts.lazy {\n\t\ttargets, err := vegeta.ReadAllTargets(tr)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ttr = vegeta.NewStaticTargeter(targets...)\n\t}\n\n\tout, err := file(opts.outputf, true)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error opening %s: %s\", opts.outputf, err)\n\t}\n\tdefer out.Close()\n\n\ttlsc, err := tlsConfig(opts.insecure, opts.certf, opts.keyf, opts.rootCerts)","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/attack.go#L147-L183","documentation":"The -format flag selects how the targets file is parsed; only the registered vegeta.TargetFormats (json, http) are supported. Any other value falls into the default branch and returns this error listing valid formats.","triggerScenarios":"`vegeta attack -format=<anything-other-than-json-or-http>`, e.g. a typo (`-format=jsson`), a removed legacy value (`gob` targets), or a programmatically supplied opts.format that is not vegeta.JSONTargetFormat or vegeta.HTTPTargetFormat.","commonSituations":"Scripts copied from very old vegeta versions that supported gob target format; users assuming CSV or plaintext formats are supported for targets; shell variables interpolating an empty or wrong format string.","solutions":["Use `-format=json` (JSON target format) or `-format=http` (plaintext HTTP target format).","Run `vegeta attack -help` to see the currently valid TargetFormats list in your version.","If migrating from gob targets, convert the input to JSON or HTTP text format first (e.g. via `vegeta encode`)."],"exampleFix":"// before\nvegeta attack -format=gob -targets=targets.gob\n// after\nvegeta encode -from=gob -to=json < targets.gob > targets.json\nvegeta attack -format=json -targets=targets.json","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"json\": true, \"http\": true}\nif !valid[format] {\n    return fmt.Errorf(\"format %q not supported; use json or http\", format)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use values from vegeta.TargetFormats for -format.","Validate format strings sourced from environment/config before passing to CLI.","Re-check valid formats after upgrading vegeta (set of formats can change)."],"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"}