{"record":{"id":"bce7cc19978088b2","repo":"docker/cli","slug":"version-mismatched-between-two-composefiles-v-a","errorCode":null,"errorMessage":"version mismatched between two composefiles : %v and %v","messagePattern":"version mismatched between two composefiles : (.+?) and (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/loader/loader.go","lineNumber":106,"sourceCode":"\t\t\tTypeCastMapping: interpolateTypeCastMapping,\n\t\t},\n\t}\n\n\tfor _, op := range opt {\n\t\top(options)\n\t}\n\n\tconfigs := []*types.Config{}\n\tvar err error\n\n\tfor _, file := range configDetails.ConfigFiles {\n\t\tconfigDict := file.Config\n\t\tversion := schema.Version(configDict)\n\t\tif configDetails.Version == \"\" {\n\t\t\tconfigDetails.Version = version\n\t\t}\n\t\tif configDetails.Version != version {\n\t\t\treturn nil, fmt.Errorf(\"version mismatched between two composefiles : %v and %v\", configDetails.Version, version)\n\t\t}\n\n\t\tif err := validateForbidden(configDict); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif !options.SkipInterpolation {\n\t\t\tconfigDict, err = interpolateConfig(configDict, *options.Interpolate)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\n\t\tif !options.SkipValidation {\n\t\t\tif err := schema.Validate(configDict, configDetails.Version); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/loader/loader.go#L88-L124","documentation":"Returned by Load when multiple compose files passed in configDetails.ConfigFiles declare different `version` keys (loader.go:99-107). Each file's version is computed via schema.Version; the first sets configDetails.Version and any subsequent file with a differing version aborts the merge.","triggerScenarios":"Passing two (or more) compose files to Load (e.g. `docker compose -f a.yml -f b.yml`) where a.yml says `version: \"3.8\"` and b.yml says `version: \"3.7\"` (or omits/changes it). Reached at loader.go:105-106.","commonSituations":"Overriding files authored against a different compose spec version; mixing a v3 file with a v2 file; a teammate bumped one file's version but not the override; inconsistent version across a split compose setup.","solutions":["Align the `version:` key across all compose files being merged (or remove it to use the latest).","Make the override file match the base file's version exactly.","If versions genuinely differ, pick one version and migrate the other file to it."],"exampleFix":"# before\n# base.yml\nversion: \"3.8\"\n# override.yml\nversion: \"3.7\"\n# after\n# base.yml\nversion: \"3.8\"\n# override.yml\nversion: \"3.8\"","handlingStrategy":"validation","validationCode":"// Ensure all compose files agree on the version key before calling loader.Load.\nfunc versionsMatch(files []types.ConfigFile) error {\n    var v string\n    for _, f := range files {\n        fv := schema.Version(f.Config)\n        if v == \"\" { v = fv; continue }\n        if fv != v {\n            return fmt.Errorf(\"version mismatched between two composefiles : %v and %v\", v, fv)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the version key identical across all merged compose files.","Prefer omitting version to use the latest spec, consistently across files.","Standardize a single version in shared override files."],"tags":["compose","loader","version","merge","schema"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}