{"record":{"id":"eaf6e1b239380c25","repo":"prestodb/presto","slug":"max-file-size-bytes-must-be-non-negative-got-s","errorCode":null,"errorMessage":"max-file-size-bytes must be non-negative, got: %s","messagePattern":"max-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":1839,"sourceCode":"        }\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    {\n        String maxFileSizeStr = options.get(\"max-file-size-bytes\");\n        if (maxFileSizeStr == null) {\n            return 0;\n        }\n        try {\n            long maxFileSize = Long.parseLong(maxFileSizeStr);\n            if (maxFileSize < 0) {\n                throw new IllegalArgumentException(\n                    String.format(\"max-file-size-bytes must be non-negative, got: %s\", maxFileSize));\n            }\n            return maxFileSize;\n        }\n        catch (NumberFormatException e) {\n            throw new IllegalArgumentException(\n                String.format(\"max-file-size-bytes must be a valid long, got: %s\", maxFileSizeStr), e);\n        }\n    }\n\n    /**\n     * Parses and validates the rewrite-all option value.\n     * Returns true if the option is set to \"true\", false otherwise.\n     */\n    public static boolean parseRewriteAll(Map<String, String> options)\n    {\n        String rewriteAllStr = options.get(\"rewrite-all\");\n        if (rewriteAllStr == null) {","sourceCodeStart":1821,"sourceCodeEnd":1857,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java#L1821-L1857","documentation":"The max-file-size-bytes optimize option caps file sizes for rewrite planning; a negative byte value is invalid, so the parser throws IllegalArgumentException with the offending value interpolated. Null means unset and returns 0.","triggerScenarios":"Calling the optimize/rewrite procedure with max-file-size-bytes='-1024' or any negative long.","commonSituations":"Overflow/sign bugs in generated configuration; sign typos; misunderstanding that 0 means 'no cap' rather than accepting negatives.","solutions":["Pass a non-negative value (0 means unset/no cap).","Omit the option entirely if no cap is desired.","Clamp in generating code: Math.max(0, configuredBytes)."],"exampleFix":"// before\nCALL system.optimize('db.t', map(ARRAY['max_file_size_bytes'], ARRAY['-1']));\n// after\nCALL system.optimize('db.t', map(ARRAY['max_file_size_bytes'], ARRAY['0']));","handlingStrategy":"validation","validationCode":"long maxFileSize = Long.parseLong(raw);\nif (maxFileSize < 0) throw new IllegalArgumentException(\"max-file-size-bytes must be >= 0\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 0 or omit the option for 'no cap' — negatives are always invalid.","Clamp values with Math.max(0, bytes) when generating options programmatically.","Validate whole option maps with a shared validator before calls."],"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"}