{"id":"ad5b332c05215942","repo":"docker/cli","slug":"duration-cannot-be-negative","errorCode":null,"errorMessage":"duration cannot be negative","messagePattern":"duration cannot be negative","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/duration.go","lineNumber":22,"sourceCode":"\t\"errors\"\n\t\"time\"\n)\n\n// PositiveDurationOpt is an option type for time.Duration that uses a pointer.\n// It behave similarly to DurationOpt but only allows positive duration values.\ntype PositiveDurationOpt struct {\n\tDurationOpt\n}\n\n// Set a new value on the option. Setting a negative duration value will cause\n// an error to be returned.\nfunc (d *PositiveDurationOpt) Set(s string) error {\n\terr := d.DurationOpt.Set(s)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif *d.DurationOpt.value < 0 {\n\t\treturn errors.New(\"duration cannot be negative\")\n\t}\n\treturn nil\n}\n\n// DurationOpt is an option type for time.Duration that uses a pointer. This\n// allows us to get nil values outside, instead of defaulting to 0\ntype DurationOpt struct {\n\tvalue *time.Duration\n}\n\n// NewDurationOpt creates a DurationOpt with the specified duration\nfunc NewDurationOpt(value *time.Duration) *DurationOpt {\n\treturn &DurationOpt{\n\t\tvalue: value,\n\t}\n}\n\n// Set a new value on the option","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/opts/duration.go#L4-L40","documentation":"Error \"duration cannot be negative\" thrown in docker/cli.","triggerScenarios":"Thrown at opts/duration.go:22 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}