{"record":{"id":"02ee70d10ef0e7c4","repo":"lima-vm/lima","slug":"option-yq-only-works-with-format-json-or-yaml","errorCode":null,"errorMessage":"option --yq only works with --format json or yaml","messagePattern":"option --yq only works with --format json or yaml","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/list.go","lineNumber":169,"sourceCode":"\tfilter, err := cmd.Flags().GetStringArray(\"filter\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif jsonFormat {\n\t\tformat = \"json\"\n\t}\n\n\t// conflicts\n\tif jsonFormat && cmd.Flags().Changed(\"format\") {\n\t\treturn errors.New(\"option --json conflicts with option --format\")\n\t}\n\tif listFields && cmd.Flags().Changed(\"format\") {\n\t\treturn errors.New(\"option --list-fields conflicts with option --format\")\n\t}\n\tif len(yq) != 0 {\n\t\tif cmd.Flags().Changed(\"format\") && format != \"json\" && format != \"yaml\" {\n\t\t\treturn errors.New(\"option --yq only works with --format json or yaml\")\n\t\t}\n\t\tif listFields {\n\t\t\treturn errors.New(\"option --list-fields conflicts with option --yq\")\n\t\t}\n\t}\n\tif len(filter) != 0 {\n\t\tif listFields {\n\t\t\treturn errors.New(\"option --list-fields conflicts with option --filter\")\n\t\t}\n\t}\n\n\tif quiet && format != \"table\" {\n\t\treturn errors.New(\"option --quiet can only be used with '--format table'\")\n\t}\n\n\tif listFields {\n\t\tnames := fieldNames()\n\t\tslices.Sort(names)","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/list.go#L151-L187","documentation":"--yq post-processes output as YAML/JSON via the yq expression engine, so it only makes sense when the underlying format is json or yaml. If an explicit --format (like table or a custom one) was given alongside --yq, listAction rejects it.","triggerScenarios":"Running e.g. `limactl list --yq '.[0].status' --format table` — yq is non-empty, --format was explicitly changed, and the value is neither json nor yaml. (Note: --yq with the default format works because the default is json.)","commonSituations":"Copy-pasting a --yq example while also adding --format table for readability; scripts where --format was added for humans but --yq kept for machines.","solutions":["Use `--format json --yq '...'` or `--format yaml --yq '...'`","Drop --format entirely (default format is compatible with --yq)","Remove --yq if you truly want human-readable table output"],"exampleFix":"// before\nlimactl list --yq '.[0].status' --format table\n// after\nlimactl list --yq '.[0].status' --format json","handlingStrategy":"validation","validationCode":"if slices.Contains(os.Args, \"--yq\") && (slices.Contains(os.Args, \"--format\") && !hasJSONOrYAMLFormat(os.Args)) {\n    // drop --format or switch to json/yaml before invoking\n}\n\nfunc hasJSONOrYAMLFormat(args []string) bool {\n    for i, a := range args {\n        if a == \"--format\" && i+1 < len(args) && (args[i+1] == \"json\" || args[i+1] == \"yaml\") { return true }\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":"if err := runList(); err != nil {\n    if strings.Contains(err.Error(), \"--yq only works with\") { /* retry with --format json */ }\n    return err\n}","preventionTips":["Pair --yq only with --format json or yaml","Remember the default format works with --yq","Don't add --format table to yq-driven scripts"],"tags":["cli","flags","yq","lima"],"backgroundTag":"conflicting-cli-flags","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}