{"record":{"id":"1a65b2aaf573da5f","repo":"t8y2/dbx","slug":"s-must-be-a-positive-integer-1a65b2","errorCode":null,"errorMessage":"%s must be a positive integer","messagePattern":"(.+?) must be a positive integer","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/iotdb/driver.go","lineNumber":372,"sourceCode":"\nfunc firstQueryValue(values url.Values, keys ...string) string {\n\tfor _, key := range keys {\n\t\tif value := strings.TrimSpace(values.Get(key)); value != \"\" {\n\t\t\treturn value\n\t\t}\n\t}\n\treturn \"\"\n}\n\nfunc queryBool(values url.Values, keys ...string) bool {\n\tvalue := strings.ToLower(firstQueryValue(values, keys...))\n\treturn value == \"1\" || value == \"true\" || value == \"yes\" || value == \"on\"\n}\n\nfunc positiveInt(value, name string) (int, error) {\n\tparsed, err := strconv.Atoi(value)\n\tif err != nil || parsed <= 0 {\n\t\treturn 0, fmt.Errorf(\"%s must be a positive integer\", name)\n\t}\n\treturn parsed, nil\n}\n\nfunc parseNodeURLs(value string) []string {\n\tparts := strings.FieldsFunc(value, func(char rune) bool { return char == ',' || char == ';' })\n\tresult := make([]string, 0, len(parts))\n\tfor _, part := range parts {\n\t\tif normalized := strings.TrimSpace(part); normalized != \"\" {\n\t\t\tresult = append(result, normalized)\n\t\t}\n\t}\n\treturn result\n}\n","sourceCodeStart":354,"sourceCodeEnd":387,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/iotdb/driver.go#L354-L387","documentation":"positiveInt is a helper used by parseConnectionConfig for numeric options like fetch_size, connect_retry_max, and connect_timeout_ms. When strconv.Atoi fails or the value is <= 0, it returns '<name> must be a positive integer' naming the offending parameter.","triggerScenarios":"Passing fetch_size=0, fetch_size=abc, fetch_size= (empty), connect_retry_max=-1, or connect_timeout_ms=100ms in the connection string query or URLParams.","commonSituations":"Values with units (100ms), thousand separators (1,000), empty strings, or values set from unvalidated environment variables/config files.","solutions":["Set the parameter to a plain positive integer without units, separators, or whitespace.","Remove the parameter to use the built-in default.","Validate numeric values programmatically before building the connection string.","Read the parameter name in the message to identify exactly which key is wrong."],"exampleFix":"// before\n\"iotdb://root:root@127.0.0.1:6667?fetch_size=100ms\"\n// after\n\"iotdb://root:root@127.0.0.1:6667?fetch_size=100\"","handlingStrategy":"validation","validationCode":"func validPositiveInt(s string) bool {\n    n, err := strconv.Atoi(strings.TrimSpace(s))\n    return err == nil && n > 0\n}\n// check before building the connection string:\n// validPositiveInt(fetchSizeParam) && validPositiveInt(retryMaxParam) && validPositiveInt(timeoutParam)","typeGuard":null,"tryCatchPattern":"cfg, err := parseConnectionConfig(params)\nif err != nil && strings.HasSuffix(err.Error(), \"must be a positive integer\") {\n    return fmt.Errorf(\"fix numeric connection option: %w\", err)\n}","preventionTips":["Store numeric options as typed ints in config, not strings.","Strip units/separators when reading values from env or files.","Validate all numeric params with Atoi before connecting."],"tags":["go","configuration","validation","numeric-parsing"],"backgroundTag":"invalid-parameter-value","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}