{"record":{"id":"98182e8ce706a374","repo":"NationalSecurityAgency/ghidra","slug":"invalid-integer-value-specified-for-98182e","errorCode":null,"errorMessage":"Invalid integer value specified for {}","messagePattern":"Invalid integer value specified for (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java","lineNumber":380,"sourceCode":"\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\"Missing required parameter (\" + name + \") before specified option: \" + p);\n\t\t}\n\t}\n\n\tprivate Integer parsePositiveIntegerOption(String option) {\n\t\tString optionValue = optionValueMap.get(option);\n\t\tif (optionValue == null) {\n\t\t\treturn null;\n\t\t}\n\t\ttry {\n\t\t\tint value = Integer.valueOf(optionValue);\n\t\t\tif (value < 0) {\n\t\t\t\tthrow new IllegalArgumentException(\"Negative value not permitted for \" + option);\n\t\t\t}\n\t\t\treturn value;\n\t\t}\n\t\tcatch (NumberFormatException e) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid integer value specified for \" + option);\n\t\t}\n\t}\n\n\t/**\n\t * Runs the command specified by the given set of params.\n\t * \n\t * @param params the parameters specifying the command\n\t * @param monitor the task monitor\n\t * @throws IllegalArgumentException if invalid params have been specified\n\t * @throws Exception if there's an error during the operation\n\t * @throws CancelledException if processing is cancelled\n\t */\n\tpublic void run(String[] params, TaskMonitor monitor) throws Exception, CancelledException {\n\n\t\tclearParams();\n\n\t\tcheckRequiredParam(params, 0, \"command\");\n\t\tString command = params[0];","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java#L362-L398","documentation":"Thrown by parsePositiveIntegerOption() when the option value cannot be parsed as an integer (Integer.valueOf throws NumberFormatException). The catch block wraps it in an IllegalArgumentException. The value is non-numeric or contains invalid characters.","triggerScenarios":"Specifying a non-numeric value for a numeric option, e.g., '--limit abc', '--maxfunc=xyz', or '--limit 1.5' (floats are not accepted, only integers).","commonSituations":"Typo in the numeric value; passing a string identifier instead of a number; using a float where an integer is required; locale-specific number formatting with commas or periods.","solutions":["Provide a valid non-negative integer value.","Ensure no whitespace, commas, or decimal points are in the value.","If the value comes from a variable, validate it is numeric before passing to BSim."],"exampleFix":"// before\nbsim listexes h2://localhost/db --limit abc\n// error: Invalid integer value specified for --limit\n\n// after\nbsim listexes h2://localhost/db --limit 50","handlingStrategy":"type-guard","validationCode":"String limitStr = optionValueMap.get(\"--limit\");\nif (limitStr != null) {\n    try {\n        Integer.parseInt(limitStr);\n    } catch (NumberFormatException e) {\n        throw new IllegalArgumentException(\"--limit value '\" + limitStr + \"' is not a valid integer\");\n    }\n}","typeGuard":"private static boolean isNonNegativeInteger(String value) {\n    if (value == null) return false;\n    try {\n        return Integer.parseInt(value) >= 0;\n    } catch (NumberFormatException e) {\n        return false;\n    }\n}","tryCatchPattern":null,"preventionTips":["Ensure numeric option values are plain integers without decimals, commas, or whitespace.","Validate user-supplied numeric input in scripts before passing to BSim.","Use Integer.parseInt() in a try-catch to pre-validate numeric arguments."],"tags":["bsim","ghidra","command-line","argument-parsing","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}