{"record":{"id":"61caaa812bdac6ce","repo":"docker/cli","slug":"1-s-2-s-1-s-driver-and-1-s-file-conflict","errorCode":null,"errorMessage":"%[1]s %[2]s: %[1]s.driver and %[1]s.file conflict; only use %[1]s.driver","messagePattern":"%\\[1\\]s %\\[2\\]s: %\\[1\\]s\\.driver and %\\[1\\]s\\.file conflict; only use %\\[1\\]s\\.driver","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/loader/loader.go","lineNumber":669,"sourceCode":"\tswitch {\n\tcase obj.External.External:\n\t\t// handle deprecated external.name\n\t\tif obj.External.Name != \"\" {\n\t\t\tif obj.Name != \"\" {\n\t\t\t\treturn obj, fmt.Errorf(\"%[1]s %[2]s: %[1]s.external.name and %[1]s.name conflict; only use %[1]s.name\", objType, name)\n\t\t\t}\n\t\t\tif versions.GreaterThanOrEqualTo(details.Version, \"3.5\") {\n\t\t\t\tlogrus.Warnf(\"%[1]s %[2]s: %[1]s.external.name is deprecated in favor of %[1]s.name\", objType, name)\n\t\t\t}\n\t\t\tobj.Name = obj.External.Name\n\t\t\tobj.External.Name = \"\"\n\t\t} else if obj.Name == \"\" {\n\t\t\tobj.Name = name\n\t\t}\n\t\t// if not \"external: true\"\n\tcase obj.Driver != \"\":\n\t\tif obj.File != \"\" {\n\t\t\treturn obj, fmt.Errorf(\"%[1]s %[2]s: %[1]s.driver and %[1]s.file conflict; only use %[1]s.driver\", objType, name)\n\t\t}\n\tdefault:\n\t\tobj.File = absPath(details.WorkingDir, obj.File)\n\t}\n\n\treturn obj, nil\n}\n\nfunc absPath(workingDir string, filePath string) string {\n\tif filepath.IsAbs(filePath) {\n\t\treturn filePath\n\t}\n\treturn filepath.Join(workingDir, filePath)\n}\n\nvar transformMapStringString TransformerFunc = func(data any) (any, error) {\n\tswitch value := data.(type) {\n\tcase map[string]any:","sourceCodeStart":651,"sourceCodeEnd":687,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/loader/loader.go#L651-L687","documentation":"Returned by loadFileObjectConfig for a non-external secret/config that sets both `driver` (bind-mounted from a driver) and `file` (path to a local file). These are mutually exclusive source modes: a driver-provided object has no local file path and vice-versa.","triggerScenarios":"A `secrets:` or `configs:` entry without `external` has both `driver:` and `file:` set.","commonSituations":"Switching a secret from a file source to a driver (e.g. secrets-bundle) and forgetting to drop `file`; copy-paste between examples.","solutions":["If using a driver, remove `file`.","If using a local file, remove `driver` (and `driver_opts`)."],"exampleFix":"# before\nsecrets:\n  token:\n    file: ./token.txt\n    driver: local\n# after\nsecrets:\n  token:\n    file: ./token.txt","handlingStrategy":"validation","validationCode":"func validateFileObjectSource(objType, name string, obj map[string]any) error {\n    ext, _ := obj[\"external\"]\n    if ext == true {\n        return nil // external handled elsewhere\n    }\n    _, hasDriver := obj[\"driver\"]\n    _, hasFile := obj[\"file\"]\n    if hasDriver && hasFile {\n        return fmt.Errorf(\"%s %s: set either driver or file, not both\", objType, name)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose one source mode per secret/config (file OR driver).","When switching modes, delete the now-unused key.","Lint rendered configs in CI."],"tags":["compose","secret","config","driver","conflict"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}