{"record":{"id":"24f7eaedd9e0cb9e","repo":"apache/shardingsphere","slug":"algorithm-s-initialization-failed-reason-is","errorCode":null,"errorMessage":"Algorithm '%s' initialization failed, reason is: %s must be a valid integer number.","messagePattern":"Algorithm '(.+?)' initialization failed, reason is: (.+?) must be a valid integer number\\.","errorType":"exception","errorClass":"AlgorithmInitializationException","httpStatus":null,"severity":"error","filePath":"features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropertiesChecker.java","lineNumber":72,"sourceCode":"        checkRequired(props, propKey, algorithm);\n        ShardingSpherePreconditions.checkNotEmpty(props.getProperty(propKey), () -> new AlgorithmInitializationException(algorithm, \"%s's length must be at least one\", propKey));\n    }\n    \n    /**\n     * check positive integer.\n     *\n     * @param props properties to be checked\n     * @param propKey properties key to be checked\n     * @param algorithm mask algorithm\n     * @throws AlgorithmInitializationException algorithm initialization exception\n     */\n    public static void checkPositiveInteger(final Properties props, final String propKey, final MaskAlgorithm<?, ?> algorithm) {\n        checkRequired(props, propKey, algorithm);\n        try {\n            int integerValue = Integer.parseInt(props.getProperty(propKey));\n            ShardingSpherePreconditions.checkState(integerValue > 0, () -> new AlgorithmInitializationException(algorithm, \"%s must be a positive integer.\", propKey));\n        } catch (final NumberFormatException ex) {\n            throw new AlgorithmInitializationException(algorithm, \"%s must be a valid integer number\", propKey);\n        }\n    }\n    \n    private static void checkRequired(final Properties props, final String requiredPropKey, final MaskAlgorithm<?, ?> algorithm) {\n        ShardingSpherePreconditions.checkContainsKey(props, requiredPropKey, () -> new AlgorithmInitializationException(algorithm, \"%s is required\", requiredPropKey));\n    }\n}\n","sourceCodeStart":54,"sourceCodeEnd":80,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropertiesChecker.java#L54-L80","documentation":"Thrown by MaskAlgorithmPropertiesChecker.checkPositiveInteger when a required mask algorithm property exists but its value cannot be parsed by Integer.parseInt. It is wrapped in AlgorithmInitializationException, so the whole mask algorithm (and rule activation) fails at init time with a message naming the property key that must be a valid integer.","triggerScenarios":"Configuring a mask algorithm such as MASK_FROM_X_TO_Y or similar with a property like from_x / to_x / replace_char-x whose value is non-numeric (e.g. 'abc', '1.5', empty, or unquoted special characters) in the MASK rule props.","commonSituations":"YAML quoting mistakes where a number is stored as a string with whitespace; copy-paste from docs with placeholder text; passing a float like '0.5' where an integer index is required; locale/format confusion after config migration.","solutions":["Set the named property to a plain positive integer string, e.g. from_x: 5","Remove any quotes, spaces, or non-numeric characters around the value in YAML","If a fractional value seems needed, re-read the algorithm's docs - these properties are character positions/counts and must be whole numbers","Restart or re-activate the mask rule so the algorithm re-initializes with corrected props"],"exampleFix":"# before\n- !MASK_ALGORITHM_FROM_X_TO_Y\n  props:\n    from_x: 'abc'\n    to_x: '#'\n# after\n- !MASK_ALGORITHM_FROM_X_TO_Y\n  props:\n    from_x: 5\n    to_x: '#'","handlingStrategy":"validation","validationCode":"String v = props.getProperty(propKey);\nif (v == null || !v.matches(\"\\\\d+\")) throw new IllegalArgumentException(propKey + \" must be a positive integer, got: \" + v);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate mask algorithm props in CI with a YAML schema/lint step","Quote numeric props consistently in YAML templates"],"tags":["mask","algorithm-init","properties","config"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}