{"id":"510c9951c882efad","repo":"docker/cli","slug":"invalid-credential-spec-cannot-specify-both-s-a","errorCode":null,"errorMessage":"invalid credential spec: cannot specify both %s, and %s","messagePattern":"invalid credential spec: cannot specify both (.+?), and (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/service.go","lineNumber":702,"sourceCode":"\tvar o []string\n\n\tif spec.Config != \"\" {\n\t\to = append(o, `\"Config\"`)\n\t}\n\tif spec.File != \"\" {\n\t\to = append(o, `\"File\"`)\n\t}\n\tif spec.Registry != \"\" {\n\t\to = append(o, `\"Registry\"`)\n\t}\n\tl := len(o)\n\tswitch {\n\tcase l == 0:\n\t\treturn nil, nil\n\tcase l == 2:\n\t\treturn nil, fmt.Errorf(\"invalid credential spec: cannot specify both %s and %s\", o[0], o[1])\n\tcase l > 2:\n\t\treturn nil, fmt.Errorf(\"invalid credential spec: cannot specify both %s, and %s\", strings.Join(o[:l-1], \", \"), o[l-1])\n\t}\n\tswarmCredSpec := swarm.CredentialSpec(spec)\n\t// if we're using a swarm Config for the credential spec, over-write it\n\t// here with the config ID\n\tif swarmCredSpec.Config != \"\" {\n\t\tfor _, config := range refs {\n\t\t\tif swarmCredSpec.Config == config.ConfigName {\n\t\t\t\tswarmCredSpec.Config = config.ConfigID\n\t\t\t\treturn &swarmCredSpec, nil\n\t\t\t}\n\t\t}\n\t\t// if none of the configs match, try namespacing\n\t\tfor _, config := range refs {\n\t\t\tif namespace.Scope(swarmCredSpec.Config) == config.ConfigName {\n\t\t\t\tswarmCredSpec.Config = config.ConfigID\n\t\t\t\treturn &swarmCredSpec, nil\n\t\t\t}\n\t\t}","sourceCodeStart":684,"sourceCodeEnd":720,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/compose/convert/service.go#L684-L720","documentation":"Error \"invalid credential spec: cannot specify both %s, and %s\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/compose/convert/service.go:702 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}