{"record":{"id":"48bf22bf0b92e2f5","repo":"k3s-io/k3s","slug":"validation-failed-for-toleration-d-v","errorCode":null,"errorMessage":"validation failed for toleration %d: %v","messagePattern":"validation failed for toleration (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cloudprovider/servicelb.go","lineNumber":720,"sourceCode":"\n// getTolerations retrieves the tolerations from a service's annotations.\n// It parses the tolerations from a JSON or YAML string stored in the annotations.\nfunc (k *k3s) getTolerations(svc *core.Service) ([]core.Toleration, error) {\n\ttolerationsStr, ok := svc.Annotations[tolerationsAnnotation]\n\tif !ok {\n\t\treturn []core.Toleration{}, nil\n\t}\n\n\tvar tolerations []core.Toleration\n\tif err := json.Unmarshal([]byte(tolerationsStr), &tolerations); err != nil {\n\t\tif err := yaml.Unmarshal([]byte(tolerationsStr), &tolerations); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse tolerations from annotation %s: %v\", tolerationsAnnotation, err)\n\t\t}\n\t}\n\n\tfor i := range tolerations {\n\t\tif err := validateToleration(&tolerations[i]); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"validation failed for toleration %d: %v\", i, err)\n\t\t}\n\t}\n\n\treturn tolerations, nil\n}\n\n// validateToleration ensures a toleration has valid fields according to its operator.\nfunc validateToleration(toleration *core.Toleration) error {\n\tif toleration.Operator == \"\" {\n\t\ttoleration.Operator = core.TolerationOpEqual\n\t}\n\n\tif toleration.Key == \"\" && toleration.Operator != core.TolerationOpExists {\n\t\treturn errors.New(\"toleration with empty key must have operator 'Exists'\")\n\t}\n\n\tif toleration.Operator == core.TolerationOpExists && toleration.Value != \"\" {\n\t\treturn errors.New(\"toleration with operator 'Exists' must have an empty value\")","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/k3s-io/k3s/blob/6ba341e396edc16b8dcae978a7c5e3ac7ee5606e/pkg/cloudprovider/servicelb.go#L702-L738","documentation":"Error \"validation failed for toleration %d: %v\" thrown in k3s-io/k3s.","triggerScenarios":"Thrown at pkg/cloudprovider/servicelb.go:720 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6ba341e396edc16b8dcae978a7c5e3ac7ee5606e","analyzedAt":"2026-08-15T16:27:54.286Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}