{"id":"e3d9d28d17478a93","repo":"docker/cli","slug":"failed-to-create-secret-s-w","errorCode":null,"errorMessage":"failed to create secret %s: %w","messagePattern":"failed to create secret (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/stack/deploy_composefile.go","lineNumber":132,"sourceCode":"\t\tres, err := apiClient.SecretInspect(ctx, secretSpec.Name, client.SecretInspectOptions{})\n\t\tswitch {\n\t\tcase err == nil:\n\t\t\t// secret already exists, then we update that\n\t\t\t_, err := apiClient.SecretUpdate(ctx, res.Secret.ID, client.SecretUpdateOptions{\n\t\t\t\tVersion: res.Secret.Meta.Version,\n\t\t\t\tSpec:    secretSpec,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to update secret %s: %w\", secretSpec.Name, err)\n\t\t\t}\n\t\tcase errdefs.IsNotFound(err):\n\t\t\t// secret does not exist, then we create a new one.\n\t\t\t_, _ = fmt.Fprintln(dockerCLI.Out(), \"Creating secret\", secretSpec.Name)\n\t\t\t_, err := apiClient.SecretCreate(ctx, client.SecretCreateOptions{\n\t\t\t\tSpec: secretSpec,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to create secret %s: %w\", secretSpec.Name, err)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc createConfigs(ctx context.Context, dockerCLI command.Cli, configs []swarm.ConfigSpec) error {\n\tapiClient := dockerCLI.Client()\n\n\tfor _, configSpec := range configs {\n\t\tres, err := apiClient.ConfigInspect(ctx, configSpec.Name, client.ConfigInspectOptions{})\n\t\tswitch {\n\t\tcase err == nil:\n\t\t\t// config already exists, then we update that\n\t\t\t_, err := apiClient.ConfigUpdate(ctx, res.Config.ID, client.ConfigUpdateOptions{\n\t\t\t\tVersion: res.Config.Meta.Version,","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/stack/deploy_composefile.go#L114-L150","documentation":"Error \"failed to create secret %s: %w\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/stack/deploy_composefile.go:132 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}