{"record":{"id":"d71d6a2ec827fc87","repo":"benbjohnson/litestream","slug":"invalid-cache-size-w","errorCode":null,"errorMessage":"invalid cache_size: %w","messagePattern":"invalid cache_size: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vfs_config.go","lineNumber":88,"sourceCode":"\t\t}\n\t\tcfg.SyncInterval = &d\n\tcase \"buffer_path\":\n\t\tcfg.BufferPath = value\n\tcase \"hydration_enabled\":\n\t\tb := strings.ToLower(value) == \"true\" || value == \"1\"\n\t\tcfg.HydrationEnabled = &b\n\tcase \"hydration_path\":\n\t\tcfg.HydrationPath = value\n\tcase \"poll_interval\":\n\t\td, err := time.ParseDuration(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid poll_interval: %w\", err)\n\t\t}\n\t\tcfg.PollInterval = &d\n\tcase \"cache_size\":\n\t\tn, err := strconv.Atoi(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid cache_size: %w\", err)\n\t\t}\n\t\tcfg.CacheSize = &n\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown config key: %s\", key)\n\t}\n\treturn nil\n}\n\nfunc ParseVFSURIConfig(uriParameters map[string]string) (*VFSConfig, error) {\n\tif len(uriParameters) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tcfg := &VFSConfig{}\n\tvar found bool\n\tfor _, key := range vfsURIConfigKeys {\n\t\tvalue, ok := uriParameters[key]\n\t\tif !ok {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/vfs_config.go#L70-L106","documentation":"Validation in the VFS URI config Set method: the cache_size parameter is not a valid integer. Fires when parsing a vfs:// URI whose cache_size query value cannot be parsed by strconv.Atoi (e.g. 'cache_size=big').","triggerScenarios":"Calling Set(\"cache_size\", <value>) — directly or via ParseVFSURIConfig — where strconv.Atoi fails, e.g. \"64MB\", \"1_000\", \"\" or \"0x100\".","commonSituations":"Writing cache_size=64MB in a URI (units not accepted); thousands separators; whitespace; templated config leaving the parameter blank.","solutions":["Provide a plain integer in bytes, e.g. cache_size=67108864","Strip units/separators from the configured value and convert to bytes yourself","Validate numeric params before building the VFS URI"],"exampleFix":"// before\nlitestream://file:///db?cache_size=64MB\n// after\nlitestream://file:///db?cache_size=67108864","handlingStrategy":"validation","validationCode":"n, err := strconv.Atoi(v)\nif err != nil { return fmt.Errorf(\"cache_size must be a plain integer (bytes): %w\", err) }\n_ = n","typeGuard":null,"tryCatchPattern":"if err := cfg.Set(\"cache_size\", v); err != nil {\n    if strings.Contains(err.Error(), \"invalid cache_size\") {\n        // convert human sizes (e.g. 64MB) to bytes before retry\n    }\n}","preventionTips":["Express cache sizes as raw byte integers in URI parameters","Convert human-readable sizes to bytes in your own config layer","Trim whitespace from templated config values"],"tags":["go","config","integer","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}