{"record":{"id":"de4b6447e7aac78e","repo":"bazelbuild/bazel","slug":"input-is-not-an-int","errorCode":null,"errorMessage":"'\" + input + \"' is not an int","messagePattern":"'\" \\+ input \\+ \"' is not an int","errorType":"validation","errorClass":"OptionsParsingException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/Converters.java","lineNumber":109,"sourceCode":"        return null;\n      }\n      return input;\n    }\n\n    @Override\n    public String getTypeDescription() {\n      return \"a string; empty to unset\";\n    }\n  }\n\n  /** Standard converter for integers. */\n  public static class IntegerConverter extends Converter.Contextless<Integer> {\n    @Override\n    public Integer convert(String input) throws OptionsParsingException {\n      try {\n        return Integer.decode(input);\n      } catch (NumberFormatException e) {\n        throw new OptionsParsingException(\"'\" + input + \"' is not an int\", e);\n      }\n    }\n\n    @Override\n    public String getTypeDescription() {\n      return \"an integer\";\n    }\n  }\n\n  /** Standard converter for longs. */\n  public static class LongConverter extends Converter.Contextless<Long> {\n    @Override\n    public Long convert(String input) throws OptionsParsingException {\n      try {\n        return Long.decode(input);\n      } catch (NumberFormatException e) {\n        throw new OptionsParsingException(\"'\" + input + \"' is not a long\", e);\n      }","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/Converters.java#L91-L127","documentation":"Thrown by Converters.IntegerConverter.convert when Integer.decode(input) raises NumberFormatException. decode() accepts decimal literals, 0x/#-prefixed hex, and 0-prefixed octal, but rejects everything else; the converter wraps the failure in an OptionsParsingException that names the offending input.","triggerScenarios":"Passing --jobs=1.5, --jobs=1,000, --jobs=\"\" (empty), --jobs=10L, or a value outside Integer range such as --jobs=99999999999 to an option using IntegerConverter.","commonSituations":"Localized number formats (thousands separators, comma decimal); copying Java literals (10L, 0xFF then mistyped as FF); values sized for a long passed to an int option; unset shell variables expanding to empty.","solutions":["Pass a plain decimal integer within int range, e.g. --jobs=1500.","Remove separators and unit suffixes from the value.","If the flag legitimately takes values beyond Integer.MAX_VALUE, check whether a long-typed flag/converter exists for it."],"exampleFix":"# before\nbazel build --jobs=1,500 //...\n# after\nbazel build --jobs=1500 //...","handlingStrategy":"validation","validationCode":"boolean isParsableInt(String s) {\n  if (s == null) return false;\n  try { Integer.decode(s); return true; }\n  catch (NumberFormatException e) { return false; }\n}","typeGuard":"boolean isIntFlagValue(String s) {\n  return s != null && s.matches(\"[+-]?(0x[0-9a-fA-F]+|0[0-7]*|[1-9][0-9]*)\");\n}","tryCatchPattern":null,"preventionTips":["Strip thousands separators and unit suffixes before passing int flags.","Validate numeric env vars once at script startup, not per flag.","Prefer plain decimal literals; hex/octal decode forms confuse readers."],"tags":["bazel","options","converter","integer","cli"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}