{"record":{"id":"7a4e81f330400347","repo":"juicedata/juicefs","slug":"negative-duration-for-s-s","errorCode":null,"errorMessage":"negative duration for %s: %s","messagePattern":"negative duration for (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/config.go","lineNumber":324,"sourceCode":"\t\t\t}\n\t\tcase \"dir-stats\":\n\t\t\tif new := ctx.Bool(flag); new != format.DirStats {\n\t\t\t\tmsg.WriteString(fmt.Sprintf(\"%10s: %t -> %t\\n\", flag, format.DirStats, new))\n\t\t\t\tformat.DirStats = new\n\t\t\t}\n\t\tcase \"changelog\":\n\t\t\tif new := ctx.Bool(flag); new != format.ChangeLog {\n\t\t\t\tmsg.WriteString(fmt.Sprintf(\"%10s: %t -> %t\\n\", flag, format.ChangeLog, new))\n\t\t\t\tformat.ChangeLog = new\n\t\t\t\tif new && format.ChangeLogMaxAge == 0 && !ctx.IsSet(\"changelog-max-age\") {\n\t\t\t\t\tformat.ChangeLogMaxAge = 7200\n\t\t\t\t\tmsg.WriteString(fmt.Sprintf(\"%10s: 0s -> %s (default)\\n\", \"changelog-max-age\", time.Duration(7200)*time.Second))\n\t\t\t\t}\n\t\t\t}\n\t\tcase \"changelog-max-age\":\n\t\t\td := ctx.Duration(flag)\n\t\t\tif d < 0 {\n\t\t\t\treturn fmt.Errorf(\"negative duration for %s: %s\", flag, d)\n\t\t\t}\n\t\t\tnewAge := int64(d.Seconds())\n\t\t\tif newAge != format.ChangeLogMaxAge {\n\t\t\t\tmsg.WriteString(fmt.Sprintf(\"%10s: %s -> %s\\n\", flag, time.Duration(format.ChangeLogMaxAge)*time.Second, d))\n\t\t\t\tformat.ChangeLogMaxAge = newAge\n\t\t\t}\n\t\tcase \"changelog-max-lines\":\n\t\t\tif new := ctx.Int64(flag); new != format.ChangeLogMaxLines {\n\t\t\t\tif new < 0 {\n\t\t\t\t\treturn fmt.Errorf(\"negative value for %s: %d\", flag, new)\n\t\t\t\t}\n\t\t\t\tmsg.WriteString(fmt.Sprintf(\"%10s: %d -> %d\\n\", flag, format.ChangeLogMaxLines, new))\n\t\t\t\tformat.ChangeLogMaxLines = new\n\t\t\t}\n\t\tcase \"user-group-quota\":\n\t\t\tif new := ctx.Bool(flag); new != format.UserGroupQuota {\n\t\t\t\tmsg.WriteString(fmt.Sprintf(\"%10s: %t -> %t\\n\", flag, format.UserGroupQuota, new))\n\t\t\t\tformat.UserGroupQuota = new","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/config.go#L306-L342","documentation":"Returned by `juicefs config` when a duration flag (changelog-max-age) is given a negative value. Durations for retention windows cannot be negative, so the update is rejected before the format is modified.","triggerScenarios":"`juicefs config META --changelog-max-age -30m` or any negative Go duration string passed to the flag.","commonSituations":"Script computing durations from signed arithmetic; misunderstanding that 0 disables retention (0 means default/unset per surrounding code).","solutions":["Pass a non-negative duration, e.g. `--changelog-max-age 2h`","Fix the computation producing the negative duration","Use 0 to fall back to the default (7200s)"],"exampleFix":"// before\njuicefs config sqlite3://test.db --changelog-max-age -1h\n// after\njuicefs config sqlite3://test.db --changelog-max-age 1h","handlingStrategy":"validation","validationCode":"case \"$AGE\" in -*) die \"changelog-max-age must be non-negative\";; esac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only pass positive Go duration strings","Use 0 to fall back to defaults","Validate durations in scripts before invoking the CLI"],"tags":["cli","validation","duration"],"backgroundTag":"invalid-duration-format","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}