{"record":{"id":"1f5ca0b88dc410cd","repo":"prestodb/presto","slug":"min-file-size-bytes-must-be-non-negative-got-s","errorCode":null,"errorMessage":"min-file-size-bytes must be non-negative, got: %s","messagePattern":"min-file-size-bytes must be non-negative, got: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java","lineNumber":1813,"sourceCode":"\n    /**\n     * Parses and validates the min-file-size-bytes option value.\n     * Returns the parsed long value, or 0 if the option is not present.\n     *\n     * @param options rewrite options map\n     * @return minimum file size threshold in bytes\n     * @throws IllegalArgumentException if the value is invalid\n     */\n    public static long parseMinFileSize(Map<String, String> options)\n    {\n        String minFileSizeStr = options.get(\"min-file-size-bytes\");\n        if (minFileSizeStr == null) {\n            return 0;\n        }\n        try {\n            long minFileSize = Long.parseLong(minFileSizeStr);\n            if (minFileSize < 0) {\n                throw new IllegalArgumentException(\n                    String.format(\"min-file-size-bytes must be non-negative, got: %s\", minFileSize));\n            }\n            return minFileSize;\n        }\n        catch (NumberFormatException e) {\n            throw new IllegalArgumentException(\n                String.format(\"min-file-size-bytes must be a valid long, got: %s\", minFileSizeStr), e);\n        }\n    }\n\n    /**\n     * Parses and validates the max-file-size-bytes option value.\n     * Returns the parsed long value, or 0 if the option is not present.\n     *\n     * @throws IllegalArgumentException if the value is invalid\n     */\n    public static long parseMaxFileSize(Map<String, String> options)\n    {","sourceCodeStart":1795,"sourceCodeEnd":1831,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java#L1795-L1831","documentation":"The min-file-size-bytes optimize option filters partitions whose files are smaller than the given size; a negative byte size is nonsensical, so the parser throws IllegalArgumentException via String.format with the offending value. Null means 'unset' and returns 0.","triggerScenarios":"Calling the optimize/rewrite procedure with min-file-size-bytes='-1' or any negative long.","commonSituations":"Arithmetic in configuration code producing negative sizes; sign typos; trying to express 'disable the filter' with a negative number instead of omitting the option or using 0.","solutions":["Pass a non-negative value (0 disables the size filter).","Omit the option entirely to use the default (0).","Clamp in generating code: Math.max(0, configuredBytes)."],"exampleFix":"// before\nCALL system.optimize('db.t', map(ARRAY['min_file_size_bytes'], ARRAY['-1048576']));\n// after\nCALL system.optimize('db.t', map(ARRAY['min_file_size_bytes'], ARRAY['1048576']));","handlingStrategy":"validation","validationCode":"long minFileSize = Long.parseLong(raw);\nif (minFileSize < 0) throw new IllegalArgumentException(\"min-file-size-bytes must be >= 0\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 0 (or omit the option) to disable the size filter — never negative values.","Clamp at config boundary: Math.max(0, bytes).","Avoid computing sizes with subtraction that can go negative."],"tags":["iceberg","validation","procedure-options","argument-parsing"],"backgroundTag":"invalid-procedure-option-value","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}