{"record":{"id":"289cafbbe9800a84","repo":"apache/flink","slug":"message","errorCode":null,"errorMessage":"${message}","messagePattern":"\\$\\{message\\}","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/table/util/ConfigurationValidatorUtil.java","lineNumber":36,"sourceCode":"\npackage org.apache.flink.connector.base.table.util;\n\nimport org.apache.flink.annotation.PublicEvolving;\nimport org.apache.flink.connector.base.table.options.ConfigurationValidator;\n\nimport java.text.ParseException;\nimport java.text.SimpleDateFormat;\nimport java.util.Properties;\n\n/** Class containing validation utils needed by {@link ConfigurationValidator}. */\n@PublicEvolving\npublic class ConfigurationValidatorUtil {\n    public static void validateOptionalBooleanProperty(\n            Properties config, String key, String message) {\n        if (config.containsKey(key)) {\n            if (!config.getProperty(key).equals(\"true\")\n                    && !config.getProperty(key).equals(\"false\")) {\n                throw new IllegalArgumentException(message);\n            }\n        }\n    }\n\n    public static void validateOptionalPositiveIntProperty(\n            Properties config, String key, String message) {\n        if (config.containsKey(key)) {\n            try {\n                int value = Integer.parseInt(config.getProperty(key));\n                if (value < 0) {\n                    throw new NumberFormatException();\n                }\n            } catch (NumberFormatException e) {\n                throw new IllegalArgumentException(message);\n            }\n        }\n    }\n","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/table/util/ConfigurationValidatorUtil.java#L18-L54","documentation":"ConfigurationValidatorUtil#validateOptionalBooleanProperty throws IllegalArgumentException (with the caller-supplied message) when a config property that is present is neither 'true' nor 'false'. Only string values exactly equal to those literals are accepted.","triggerScenarios":"A Properties config contains a key expected to be boolean but with a value like '1', 'yes', 'TRUE ' (with trailing space), or any non-literal.","commonSituations":"Properties file with non-canonical boolean strings; migration from a system that used 0/1; trailing whitespace in config values.","solutions":["Set the property value to exactly 'true' or 'false' (lowercase, no whitespace).","If loading from a file, trim whitespace before validation.","Pre-validate the property and normalize it (e.g. parse Boolean.parseString then write back the canonical form)."],"exampleFix":"// before\nprops.setProperty(\"enable-feature\", \"1\");\nConfigurationValidatorUtil.validateOptionalBooleanProperty(props, \"enable-feature\", msg);\n// after\nprops.setProperty(\"enable-feature\", \"true\");","handlingStrategy":"validation","validationCode":"static void ensureBoolean(Properties p, String k) {\n    if (p.containsKey(k)) {\n        String v = p.getProperty(k).trim();\n        if (!v.equals(\"true\") && !v.equals(\"false\")) {\n            throw new IllegalArgumentException(k + \" must be 'true' or 'false' but was: \" + v);\n        }\n        p.setProperty(k, v);\n    }\n}","typeGuard":"static boolean isCanonicalBoolean(Properties p, String k) {\n    return !p.containsKey(k)\n        || p.getProperty(k).equals(\"true\")\n        || p.getProperty(k).equals(\"false\");\n}","tryCatchPattern":null,"preventionTips":["Use exactly 'true'/'false' (lowercase) for boolean properties.","Trim whitespace when loading properties from files.","Normalize non-canonical values (1/0, yes/no) before validation."],"tags":["config-validation","boolean","properties","flink"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}