{"record":{"id":"be1a2bf43d0f24ee","repo":"glanceapp/glance","slug":"invalid-duration-format-s","errorCode":null,"errorMessage":"invalid duration format: %s","messagePattern":"invalid duration format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/config-fields.go","lineNumber":110,"sourceCode":"\n\treturn nil\n}\n\nvar durationFieldPattern = regexp.MustCompile(`^(\\d+)(s|m|h|d)$`)\n\ntype durationField time.Duration\n\nfunc (d *durationField) UnmarshalYAML(node *yaml.Node) error {\n\tvar value string\n\n\tif err := node.Decode(&value); err != nil {\n\t\treturn err\n\t}\n\n\tmatches := durationFieldPattern.FindStringSubmatch(value)\n\n\tif len(matches) != 3 {\n\t\treturn fmt.Errorf(\"invalid duration format: %s\", value)\n\t}\n\n\tduration, err := strconv.Atoi(matches[1])\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tswitch matches[2] {\n\tcase \"s\":\n\t\t*d = durationField(time.Duration(duration) * time.Second)\n\tcase \"m\":\n\t\t*d = durationField(time.Duration(duration) * time.Minute)\n\tcase \"h\":\n\t\t*d = durationField(time.Duration(duration) * time.Hour)\n\tcase \"d\":\n\t\t*d = durationField(time.Duration(duration) * 24 * time.Hour)\n\t}\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/config-fields.go#L92-L128","documentation":"Returned by durationField.UnmarshalYAML when a duration value in config does not match the strict pattern ^(\\d+)(s|m|h|d)$ — a whole number followed by exactly one unit letter (seconds, minutes, hours, days). No combined units, no decimals, no ms/µs, no bare numbers are accepted.","triggerScenarios":"Writing cache: 90 (no unit), cache: 1h30m, cache: 1.5h, cache: 500ms, cache: 1 w, or cache: 1H (uppercase). Any of these fails FindStringSubmatch with fewer than 3 groups.","commonSituations":"Assuming Go duration string syntax (1h30m) is accepted; writing milliseconds; uppercase units; fractional values like 0.5d; bare seconds without 's'.","solutions":["Use a single integer plus one unit: e.g. cache: 90s, cache: 30m, cache: 12h, cache: 7d.","Convert combined durations to the largest unit (90m → 1h loses precision, so use 5400s or 90m as appropriate).","Convert decimals to a smaller unit (0.5h → 30m).","Validate with `glance config:validate` after editing."],"exampleFix":"# before\ncache: 1h30m\n\n# after\ncache: 90m","handlingStrategy":"validation","validationCode":"python3 - <<'EOF'\nimport re,sys,yaml\npat=re.compile(r'^(\\d+)(s|m|h|d)$')\ndef walk(o):\n    if isinstance(o,dict):\n        for k,v in o.items():\n            if k in ('cache','cache-duration','secret-effect-duration') and isinstance(v,str) and not pat.match(v):\n                sys.exit(f'bad duration: {k}={v}')\n            walk(v)\n    elif isinstance(o,list):\n        for i in o: walk(i)\nwalk(yaml.safe_load(open('glance.yml')))\nprint('ok')\nEOF","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use one integer + one of s/m/h/d only; no Go-style 1h30m, no ms, no decimals.","Convert decimals to smaller units (0.5h → 30m)."],"tags":["config","duration","validation","yaml"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}