{"record":{"id":"cc212b7a5c3e9269","repo":"docker/cli","slug":"invalid-restart-policy-unknown-policy-s-must","errorCode":null,"errorMessage":"invalid restart policy: unknown policy '%s' (must be one of '%s', '%s', '%s', or '%s')","messagePattern":"invalid restart policy: unknown policy '(.+?)' \\(must be one of '(.+?)', '(.+?)', '(.+?)', or '(.+?)'\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/service.go","lineNumber":522,"sourceCode":"\t\tp := uint64(i)\n\t\treturn &p\n\t}\n\n\tswitch policy.Name {\n\tcase container.RestartPolicyDisabled, \"\":\n\t\treturn nil, nil\n\tcase container.RestartPolicyAlways, container.RestartPolicyUnlessStopped:\n\t\treturn &swarm.RestartPolicy{\n\t\t\tCondition:   swarm.RestartPolicyConditionAny,\n\t\t\tMaxAttempts: uint64Ptr(policy.MaximumRetryCount),\n\t\t}, nil\n\tcase container.RestartPolicyOnFailure:\n\t\treturn &swarm.RestartPolicy{\n\t\t\tCondition:   swarm.RestartPolicyConditionOnFailure,\n\t\t\tMaxAttempts: uint64Ptr(policy.MaximumRetryCount),\n\t\t}, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid restart policy: unknown policy '%s' (must be one of '%s', '%s', '%s', or '%s')\",\n\t\t\tpolicy.Name, container.RestartPolicyDisabled, container.RestartPolicyAlways, container.RestartPolicyOnFailure, container.RestartPolicyUnlessStopped,\n\t\t)\n\t}\n}\n\nfunc convertUpdateConfig(source *composetypes.UpdateConfig) *swarm.UpdateConfig {\n\tif source == nil {\n\t\treturn nil\n\t}\n\tparallel := uint64(1)\n\tif source.Parallelism != nil {\n\t\tparallel = *source.Parallelism\n\t}\n\treturn &swarm.UpdateConfig{\n\t\tParallelism:     parallel,\n\t\tDelay:           time.Duration(source.Delay),\n\t\tFailureAction:   swarm.FailureAction(source.FailureAction),\n\t\tMonitor:         time.Duration(source.Monitor),","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/convert/service.go#L504-L540","documentation":"Returned by the restart-policy converter's default branch when policy.Name does not match any of the supported Swarm conditions (service.go:508-525). Swarm only accepts 'no'/'', 'always', 'unless-stopped', and 'on-failure'; any other string is rejected with a message listing the valid values.","triggerScenarios":"Setting deploy.restart_policy.condition to a value other than the four enumerated constants (e.g. 'whenever', 'never', 'restart'). Reached at service.go:521 default case.","commonSituations":"Using container-engine restart-policy names that aren't valid Swarm conditions; typos like 'allways'; copy-pasting a policy from a non-Swarm compose example.","solutions":["Set deploy.restart_policy.condition to one of: 'no', 'always', 'unless-stopped', 'on-failure'.","Remove the restart_policy block to use the default (disabled) behavior.","Double-check spelling against the four values listed in the error message."],"exampleFix":"// before\ndeploy:\n  restart_policy:\n    condition: whenever\n// after\ndeploy:\n  restart_policy:\n    condition: on-failure\n    max_attempts: 3","handlingStrategy":"validation","validationCode":"var validRestartConditions = map[string]bool{\n    \"\": true, \"no\": true, \"always\": true, \"on-failure\": true, \"unless-stopped\": true,\n}\nfunc validateRestartPolicy(cfg *composetypes.Config) error {\n    for _, svc := range cfg.Services {\n        if n := svc.Deploy.RestartPolicy.Name; n != \"\" && !validRestartConditions[n] {\n            return fmt.Errorf(\"invalid restart policy: unknown policy %q\", n)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict deploy.restart_policy.condition to the four Swarm-supported values.","Leave restart_policy unset to use the default (disabled).","Add a schema/lint check for restart conditions in CI."],"tags":["compose","convert","restart-policy","swarm","deploy"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}