{"record":{"id":"4eb4de43a2a02914","repo":"docker/compose","slug":"error-unmarshalling-available-models-w","errorCode":null,"errorMessage":"error unmarshalling available models: %w","messagePattern":"error unmarshalling available models: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compose/model.go","lineNumber":274,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toutput, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error checking available models: %w\", err)\n\t}\n\n\ttype AvailableModel struct {\n\t\tId      string   `json:\"id\"`\n\t\tTags    []string `json:\"tags\"`\n\t\tCreated int      `json:\"created\"`\n\t}\n\n\tmodels := []AvailableModel{}\n\terr = json.Unmarshal(output, &models)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error unmarshalling available models: %w\", err)\n\t}\n\tvar availableModels []string\n\tfor _, model := range models {\n\t\tavailableModels = append(availableModels, model.Tags...)\n\t}\n\treturn availableModels, nil\n}\n\n// supportsRuntimeFlags checks if the docker model version supports runtime flags\n// Runtime flags are supported in version >= v1.0.6\nfunc (m *modelAPI) supportsRuntimeFlags() bool {\n\t// If version is not cached, don't append runtime flags to be safe\n\tif m.version == \"\" {\n\t\treturn false\n\t}\n\n\t// Strip 'v' prefix if present (e.g., \"v1.0.6\" -> \"1.0.6\")\n\tversionStr := strings.TrimPrefix(m.version, \"v\")","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/compose/model.go#L256-L292","documentation":"After `docker model ls --json` succeeds, compose unmarshals its stdout into a []AvailableModel. If the bytes are not that JSON shape, unmarshalling fails and is wrapped here. The plugin exited 0 but emitted something other than the expected array (or stdout is polluted by warnings).","triggerScenarios":"Plugin output containing a leading warning/log line before the JSON; schema change in a newer/older plugin (object instead of array); empty output; text error printed on stdout with exit 0.","commonSituations":"Version skew between compose and the model plugin; plugins that log to stdout; locale/env-triggered notices corrupting machine-readable output.","solutions":["Capture and inspect the raw output: docker model ls --json | head; check it starts with '['","Align versions: upgrade compose and/or the model plugin so their contract matches","Report/fix the plugin if it prints non-JSON noise on stdout"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"out, err := exec.Command(\"docker\", \"model\", \"ls\", \"--json\").Output()\nif err != nil { return err }\nif !json.Valid(out) || !bytes.HasPrefix(bytes.TrimSpace(out), []byte(\"[\")) {\n    return errors.New(\"model plugin emitted unexpected output; align plugin and compose versions\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin compatible versions of compose and the model plugin together","Keep plugin stdout reserved for machine-readable output; route logs to stderr"],"tags":["models","json","plugin","schema"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}