{"record":{"id":"1d3aba64ec5e791c","repo":"goharbor/harbor","slug":"s-is-less-than-zero-1d3aba","errorCode":null,"errorMessage":"%s is less than zero","messagePattern":"(.+?) is less than zero","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/pkg/retention/policy/rule/latestps/evaluator.go","lineNumber":85,"sourceCode":"\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tlog.Warningf(\"default parameter %d used for rule %s\", DefaultK, TemplateID)\n\n\treturn &evaluator{\n\t\tk: DefaultK,\n\t}\n}\n\n// Valid ...\nfunc Valid(params rule.Parameters) error {\n\tif params != nil {\n\t\tif p, ok := params[ParameterK]; ok {\n\t\t\tif v, ok := utils.ParseJSONInt(p); ok {\n\t\t\t\tif v < 0 {\n\t\t\t\t\treturn fmt.Errorf(\"%s is less than zero\", ParameterK)\n\t\t\t\t}\n\t\t\t\tif v >= math.MaxInt16 {\n\t\t\t\t\treturn fmt.Errorf(\"%s is too large\", ParameterK)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"%s type error\", ParameterK)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":67,"sourceCodeEnd":97,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/pkg/retention/policy/rule/latestps/evaluator.go#L67-L97","documentation":"Validation guard in the latestps (latest K pushed artifacts) rule's Valid function: the 'k' count parameter parsed as a JSON integer was negative. A retained-artifact count cannot be negative, so the rule definition is rejected before it is persisted.","triggerScenarios":"Thrown at src/pkg/retention/policy/rule/latestps/evaluator.go:85 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set k to 0 or a positive integer for how many most-recently-pushed tags to keep","Validate counts client-side before submitting the retention policy","Only explicit negative values fail; omitting k applies a default"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","contentChangedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}