{"id":"6b0e3f4102cbcb1a","repo":"docker/cli","slug":"invalid-credential-spec-cannot-specify-both-s-an","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":700,"sourceCode":"\nfunc convertCredentialSpec(namespace Namespace, spec composetypes.CredentialSpecConfig, refs []*swarm.ConfigReference) (*swarm.CredentialSpec, error) {\n\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","sourceCodeStart":682,"sourceCodeEnd":718,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/compose/convert/service.go#L682-L718","documentation":"Error \"invalid credential spec: cannot specify both %s and %s\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/compose/convert/service.go:700 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}