{"record":{"id":"4651aab5527c517e","repo":"abiosoft/colima","slug":"error-parsing-model-list-w","errorCode":null,"errorMessage":"error parsing model list: %w","messagePattern":"error parsing model list: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"model/runner.go","lineNumber":195,"sourceCode":"\treturn \"\", nil\n}\n\n// listDockerModels returns all available models from docker model list.\nfunc listDockerModels() ([]dockerModel, error) {\n\tguest := lima.New(host.New())\n\toutput, err := guest.RunOutput(\"docker\", \"model\", \"list\", \"--json\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing models: %w\", err)\n\t}\n\n\toutput = strings.TrimSpace(output)\n\tif output == \"\" || output == \"[]\" {\n\t\treturn nil, nil\n\t}\n\n\tvar models []dockerModel\n\tif err := json.Unmarshal([]byte(output), &models); err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing model list: %w\", err)\n\t}\n\n\treturn models, nil\n}\n\n// ResolveModelName resolves a short model name to its full tag.\n// Supports flexible matching:\n//   - \"smollm2\" resolves to \"docker.io/ai/smollm2:latest\"\n//   - \"ai/smollm2\" resolves to \"docker.io/ai/smollm2:latest\"\n//   - \"hf.co/...\" resolves to \"huggingface.co/...\"\n//\n// Returns the original name if no match is found (for new models to be pulled).\nfunc ResolveModelName(name string) (string, error) {\n\tmodels, err := listDockerModels()\n\tif err != nil {\n\t\treturn name, err\n\t}\n","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/model/runner.go#L177-L213","documentation":"The stdout of `docker model list --json` could not be unmarshalled into []dockerModel. Empty output and `[]` are handled just before, so this fires when the payload is JSON mixed with non-JSON noise (CLI warnings, banner lines) or when the shape changed (object instead of array) — typically version skew between the VM's docker model plugin and this parser.","triggerScenarios":"A newer or older docker model plugin printing warnings or a wrapper object to stdout; VM shell interleaving log lines with the JSON payload; any plugin output-format change.","commonSituations":"Version mismatch after upgrading the VM's docker engine but not colima, or vice versa.","solutions":["Dump the raw payload to see what is extra: colima ssh -- docker model list --json","Align versions: upgrade colima and/or the VM docker engine so the output matches the expected schema","If you control the caller, strip non-JSON noise before Unmarshal (see example fix)"],"exampleFix":"// before\nvar models []dockerModel\nif err := json.Unmarshal([]byte(output), &models); err != nil {\n\treturn nil, fmt.Errorf(\"error parsing model list: %w\", err)\n}\n\n// after: drop CLI noise around the JSON array\nif s := strings.Index(output, \"[\"); s > 0 {\n\tif e := strings.LastIndex(output, \"]\"); e > s {\n\t\toutput = output[s : e+1]\n\t}\n}\nvar models []dockerModel\nif err := json.Unmarshal([]byte(output), &models); err != nil {\n\treturn nil, fmt.Errorf(\"error parsing model list: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"var typeErr *json.UnmarshalTypeError\nif errors.As(err, &typeErr) {\n\t// payload shape changed (object vs array): version skew — dump raw output and align versions\n} else {\n\t// SyntaxError: noise in stdout — sanitize around the JSON array and retry once\n}","preventionTips":["Upgrade colima and the VM docker engine together","When shelling out for JSON, capture stderr separately and validate that stdout is pure JSON before parsing"],"tags":["json","parsing","docker","version-skew","go"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}