{"record":{"id":"ccb27cb197d4ddee","repo":"abiosoft/colima","slug":"error-parsing-model-info-w","errorCode":null,"errorMessage":"error parsing model info: %w","messagePattern":"error parsing model info: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"model/docker.go","lineNumber":107,"sourceCode":"\n\tif err := guest.RunQuiet(\"docker\", \"exec\", \"docker-model-runner\", \"ln\", blobPath, bundlePath); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to link model file: %w\", err)\n\t}\n\n\treturn bundlePath, nil\n}\n\n// InspectDockerModel returns information about a Docker model.\nfunc InspectDockerModel(modelName string) (*DockerModelInfo, error) {\n\tguest := lima.New(host.New())\n\toutput, err := guest.RunOutput(\"docker\", \"model\", \"inspect\", modelName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error inspecting model %q: %w\", modelName, err)\n\t}\n\n\tvar info DockerModelInfo\n\tif err := json.Unmarshal([]byte(strings.TrimSpace(output)), &info); err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing model info: %w\", err)\n\t}\n\n\treturn &info, nil\n}\n\n// SetupOrUpdateDocker reinstalls Docker Model Runner in the VM.\nfunc SetupOrUpdateDocker() error {\n\tguest := lima.New(host.New())\n\n\tlog.Println(\"reinstalling Docker Model Runner...\")\n\n\tif err := guest.RunInteractive(\"docker\", \"model\", \"reinstall-runner\"); err != nil {\n\t\treturn fmt.Errorf(\"error reinstalling Docker Model Runner: %w\", err)\n\t}\n\n\tlog.Println(\"Docker Model Runner reinstalled\")\n\n\t// Print installed version","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/model/docker.go#L89-L125","documentation":"InspectDockerModel json.Unmarshals the trimmed stdout of docker model inspect into DockerModelInfo. The output was not the expected JSON object: the CLI emitted human-readable text, a warning preamble, or nothing; or a Docker version changed the inspect output schema so fields moved.","triggerScenarios":"docker model inspect printing a banner/hint lines before JSON on some Docker versions; inspect writing to stdout an error string instead of failing; empty output when the CLI exits 0 without data; schema drift in newer Docker Model Runner releases.","commonSituations":"Colima version lagging behind a freshly updated Docker in the VM; locale/TTY-dependent CLI output; models with unusual metadata producing partial JSON.","solutions":["Capture the raw output manually: colima ssh -- docker model inspect <name> and compare it to the fields DockerModelInfo expects","Update colima (which pins matching parsing) and/or the Docker engine in the VM to matching versions","If the CLI supports it, request machine-readable output explicitly (docker model inspect --format json or equivalent) in a local patch","On persistent mismatch, fall back to parsing docker model ls --json entries for the model"],"exampleFix":"// before\nvar info DockerModelInfo\nif err := json.Unmarshal([]byte(strings.TrimSpace(output)), &info); err != nil {\n    return nil, fmt.Errorf(\"error parsing model info: %w\", err)\n}\n\n// after: keep only the JSON object in the output\nvar info DockerModelInfo\ntrimmed := strings.TrimSpace(output)\nif i := strings.Index(trimmed, \"{\"); i > 0 {\n    trimmed = trimmed[i:]\n}\nif err := json.Unmarshal([]byte(trimmed), &info); err != nil {\n    return nil, fmt.Errorf(\"error parsing model info: %w (output: %.200q)\", err, output)\n}","handlingStrategy":"try-catch","validationCode":"// Pre-trim CLI chatter so only the JSON object is unmarshalled.\nfunc extractJSON(s string) string {\n    if i := strings.Index(s, \"{\"); i >= 0 {\n        if j := strings.LastIndex(s, \"}\"); j > i {\n            return s[i : j+1]\n        }\n    }\n    return s\n}","typeGuard":null,"tryCatchPattern":"var info DockerModelInfo\nif err := json.Unmarshal([]byte(extractJSON(output)), &info); err != nil {\n    return nil, fmt.Errorf(\"error parsing model info: %w (docker model inspect output: %.200q)\", err, output)\n}","preventionTips":["Pin docker/colima versions that were released together — inspect output schema drifts across Docker releases","Always include a truncated copy of the failing CLI output in parse errors","Prefer structured output flags (json templates) over parsing human-oriented stdout when available"],"tags":["json","docker","inspect","schema-drift"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}