{"record":{"id":"d5e090be0ffdb516","repo":"SigNoz/signoz","slug":"errcodepublicdashboardinvalidinput-d5e090","errorCode":"ErrCodePublicDashboardInvalidInput","errorMessage":"unable to parse defaultTimeRange %s","messagePattern":"unable to parse defaultTimeRange (.+?)","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/types/dashboardtypes/public_dashboard.go","lineNumber":250,"sourceCode":"\ttimeRange, err := time.ParseDuration(typ.DefaultTimeRange)\n\tif err != nil {\n\t\treturn 0, 0, errors.WrapInternalf(err, errors.CodeInternal, \"stored defaultTimeRange %q is not a valid duration\", typ.DefaultTimeRange)\n\t}\n\tnow := time.Now()\n\treturn uint64(now.Add(-timeRange).UnixMilli()), uint64(now.UnixMilli()), nil\n}\n\nfunc (typ *PostablePublicDashboard) UnmarshalJSON(data []byte) error {\n\ttype alias PostablePublicDashboard\n\tvar temp alias\n\n\tif err := json.Unmarshal(data, &temp); err != nil {\n\t\treturn err\n\t}\n\n\t_, err := time.ParseDuration(temp.DefaultTimeRange)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, errors.TypeInvalidInput, ErrCodePublicDashboardInvalidInput, \"unable to parse defaultTimeRange %s\", temp.DefaultTimeRange)\n\t}\n\n\t*typ = PostablePublicDashboard(temp)\n\treturn nil\n}\n\nfunc (typ *UpdatablePublicDashboard) UnmarshalJSON(data []byte) error {\n\ttype alias UpdatablePublicDashboard\n\tvar temp alias\n\n\tif err := json.Unmarshal(data, &temp); err != nil {\n\t\treturn err\n\t}\n\n\t_, err := time.ParseDuration(temp.DefaultTimeRange)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, errors.TypeInvalidInput, ErrCodePublicDashboardInvalidInput, \"unable to parse defaultTimeRange %s\", temp.DefaultTimeRange)\n\t}","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/types/dashboardtypes/public_dashboard.go#L232-L268","documentation":"PostablePublicDashboard.UnmarshalJSON parses the incoming public-dashboard payload and requires the DefaultTimeRange field to be a valid Go duration string (time.ParseDuration, e.g. \"30m\", \"24h\"). If parsing fails, the request is rejected with ErrCodePublicDashboardInvalidInput including the offending value.","triggerScenarios":"POST/PUT of a public dashboard (create/update endpoint) whose JSON body has defaultTimeRange like \"30 minutes\", \"1d\", \"30sec\", \"\", or an ISO 8601 duration (\"PT30M\") — none are accepted by time.ParseDuration (which wants \"30m\", \"1h30m\", \"0.5h\").","commonSituations":"Frontends or scripts copying duration formats from other tools (ISO 8601, human text); omitting the field when the type defaults to empty string; unit suffix typos like \"30M\" (uppercase M is minutes? no—ParseDuration is case-sensitive: 'M' is invalid, only m/h/s/ms/us/ns).","solutions":["Use exact Go duration syntax: ns, us (or µs), ms, s, m, h, e.g. \"30m\", \"1h\", \"45s\"","Compound values are allowed like \"1h30m\"; decimals like \"1.5h\" also work","Verify no stray whitespace or quotes around the value in the JSON body"],"exampleFix":"// before\n{\"defaultTimeRange\": \"30 minutes\"}\n\n// after\n{\"defaultTimeRange\": \"30m\"}","handlingStrategy":"validation","validationCode":"if _, err := time.ParseDuration(payload.DefaultTimeRange); err != nil {\n    payload.DefaultTimeRange = \"1h\" // or reject\n}","typeGuard":"func isValidGoDuration(s string) bool { _, err := time.ParseDuration(s); return err == nil }","tryCatchPattern":null,"preventionTips":["Use Go units (m/h/s) in all duration fields","Centralize duration formatting in one client helper"],"tags":["duration","parse","public-dashboard","validation"],"backgroundTag":"invalid-duration-format","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}