{"record":{"id":"7f345f90b69bec17","repo":"matryer/xbar","slug":"invalid-refresh-interval","errorCode":null,"errorMessage":"invalid refresh interval","messagePattern":"invalid refresh interval","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plugins/refresh_interval.go","lineNumber":70,"sourceCode":"\t\treturn fmt.Sprintf(\"%dd\", r.N)\n\tcase \"hours\":\n\t\treturn fmt.Sprintf(\"%dh\", r.N)\n\tcase \"minutes\":\n\t\treturn fmt.Sprintf(\"%dm\", r.N)\n\tcase \"seconds\":\n\t\treturn fmt.Sprintf(\"%ds\", r.N)\n\tcase \"milliseconds\":\n\t\treturn fmt.Sprintf(\"%dms\", r.N)\n\tdefault:\n\t\treturn \"<invalid>\"\n\t}\n}\n\n// SetRefreshInterval sets the time interval at which a plugin should be re-run.\nfunc SetRefreshInterval(pluginDirectory, installedPluginPath string, refreshInterval RefreshInterval) (string, RefreshInterval, error) {\n\tinterval := findIntervalInFilename(installedPluginPath)\n\tif err := validateRefreshInterval(refreshInterval); err != nil {\n\t\treturn \"\", RefreshInterval{}, errors.Wrap(err, \"invalid refresh interval\")\n\t}\n\toldFullPath := filepath.Join(pluginDirectory, installedPluginPath)\n\tnewFilename := strings.Replace(installedPluginPath, \".\"+interval+\".\", \".\"+refreshInterval.String()+\".\", 1)\n\tnewFullPath := filepath.Join(pluginDirectory, newFilename)\n\tif err := os.Rename(oldFullPath, newFullPath); err != nil {\n\t\treturn \"\", RefreshInterval{}, errors.Wrap(err, \"rename plugin file to new refresh interval\")\n\t}\n\t_, err := os.Stat(newFullPath)\n\tif err != nil {\n\t\treturn \"\", RefreshInterval{}, errors.Wrap(err, \"stat plugin file\")\n\t}\n\toldVarFullPath := oldFullPath + variableJSONFileExt\n\t_, err = os.Stat(oldVarFullPath)\n\tif err != nil && !os.IsNotExist(err) {\n\t\treturn \"\", RefreshInterval{}, errors.Wrap(err, \"stat plugin vars file\")\n\t}\n\tif err != nil && os.IsNotExist(err) {\n\t\t// no variable file, no probs","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/plugins/refresh_interval.go#L52-L88","documentation":"SetRefreshInterval renames a plugin file to embed a new refresh interval and validates the requested interval first. This error wraps validateRefreshInterval's rejection — the supplied RefreshInterval is not one of the supported values, so no rename is performed.","triggerScenarios":"Calling SetRefreshInterval(pluginDirectory, installedPluginPath, refreshInterval) with a refreshInterval that fails validateRefreshInterval — e.g. zero-value RefreshInterval{}, a hand-built struct with an unrecognized seconds value, or one not matching the fixed set of intervals.","commonSituations":"External tools constructing a RefreshInterval manually instead of using the library's predefined constants; UI storing an interval that changed between library versions; config files with stale/unsupported interval numbers.","solutions":["Use one of the library's predefined RefreshInterval constants rather than constructing one manually","Check the wrapped error (errors.Cause) to see exactly what validation rejected","If storing intervals externally, re-normalize them against the current library's supported set","Verify the plugin's installed filename actually contains an interval segment (e.g. name.5m.sh) via findIntervalInFilename"],"exampleFix":"// before\ninterval := RefreshInterval{Seconds: 45}          // unsupported value\nSetRefreshInterval(dir, path, interval)\n// after\ninterval := RefreshInterval5m                      // predefined constant\nSetRefreshInterval(dir, path, interval)","handlingStrategy":"validation","validationCode":"switch refreshInterval.String() {\ncase \"1m\", \"5m\", \"10m\", \"15m\", \"30m\", \"1h\": // supported set per library docs\ndefault:\n    return fmt.Errorf(\"unsupported refresh interval %q\", refreshInterval.String())\n}","typeGuard":null,"tryCatchPattern":"newPath, _, err := plugins.SetRefreshInterval(dir, path, interval)\nif err != nil {\n    var verr error\n    if errors.As(err, &verr) && errors.Unwrap(err) != nil {\n        log.Printf(\"interval rejected: %v\", errors.Unwrap(err))\n    }\n    interval = plugins.RefreshInterval5m // fall back to a known-good interval\n}","preventionTips":["Always use the library's predefined RefreshInterval constants","Never hand-construct RefreshInterval structs with arbitrary seconds","Keep stored/configured intervals in sync with the library's supported set when upgrading"],"tags":["plugins","refresh-interval","validation","configuration"],"backgroundTag":"invalid-refresh-interval","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}