{"record":{"id":"5b4c96ccdc6c8db6","repo":"AdguardTeam/AdGuardHome","slug":"unsupported-interval-w-5b4c96","errorCode":null,"errorMessage":"unsupported interval: %w","messagePattern":"unsupported interval: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/stats/stats.go","lineNumber":160,"sourceCode":"\n\t// filename is the name of database file.\n\tfilename string\n\n\t// limit is an upper limit for collecting statistics.\n\tlimit time.Duration\n\n\t// enabled tells if the statistics are enabled.\n\tenabled bool\n}\n\n// New creates s from conf and properly initializes it.  Don't use s before\n// calling it's Start method.\nfunc New(conf Config) (s *StatsCtx, err error) {\n\tdefer withRecovered(&err)\n\n\terr = validateIvl(conf.Limit)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unsupported interval: %w\", err)\n\t}\n\n\tif conf.ShouldCountClient == nil {\n\t\treturn nil, errors.Error(\"should count client is unspecified\")\n\t}\n\n\ts = &StatsCtx{\n\t\tlogger:         conf.Logger,\n\t\tcurrMu:         &sync.RWMutex{},\n\t\thttpReg:        conf.HTTPReg,\n\t\tconfigModifier: conf.ConfigModifier,\n\t\tfilename:       conf.Filename,\n\n\t\tconfMu:            &sync.RWMutex{},\n\t\tignored:           conf.Ignored,\n\t\tshouldCountClient: conf.ShouldCountClient,\n\t\tlimit:             conf.Limit,\n\t\tenabled:           conf.Enabled,","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/stats/stats.go#L142-L178","documentation":"StatsCtx.New rejects the configured stats interval (Limit) because validateIvl considers it unsupported; the underlying validation error is wrapped as 'unsupported interval'.","triggerScenarios":"Calling stats.New with a Config whose Limit is outside the supported range or not a valid interval (e.g. 0, negative, or not a multiple of an hour), as validated by validateIvl.","commonSituations":"Misconfigured stats interval in YAML/JSON config (typo, wrong unit, 0), or upgrading to a version that restricts the allowed set of intervals.","solutions":["Set Config.Limit to a supported interval, typically a whole number of hours within the min/max window","Check validateIvl's bounds in internal/stats and align the config","Fail fast at config load with a clear message"],"exampleFix":"// before\nconf := stats.Config{Limit: 30 * time.Minute}\n// after\nconf := stats.Config{Limit: 24 * time.Hour}","handlingStrategy":"validation","validationCode":"ivl := conf.Limit.Truncate(time.Hour)\nif ivl < time.Hour || ivl%time.Hour != 0 { return errors.New(\"limit must be whole hours within supported range\") }","typeGuard":null,"tryCatchPattern":"s, err := stats.New(conf)\nif err != nil { if strings.Contains(err.Error(), \"unsupported interval\") { fixLimit() } }","preventionTips":["Pin the interval to documented supported values","Validate config in a loader before constructing StatsCtx"],"tags":["stats","config-validation","interval"],"backgroundTag":"config-validation-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}