{"record":{"id":"2f8324c8f0424c46","repo":"JetBrains/intellij-community","slug":"invalid-precision-specified-in-0","errorCode":null,"errorMessage":"invalid precision specified in ''{0}''","messagePattern":"invalid precision specified in ''(.+?)''","errorType":"exception","errorClass":"FormatDecode.IllegalFormatException","httpStatus":null,"severity":"error","filePath":"java/java-analysis-impl/src/com/siyeh/ig/format/FormatDecode.java","lineNumber":359,"sourceCode":"          case 'a', 'A' -> { // hexadecimal floating-point number\n            checkFlags(flagBits, ~(PARENTHESES | GROUP), specifier);\n            allowed = new FloatValidator(specifier);\n          }\n          case 'e', 'E' -> { // floating point -> decimal number in computerized scientific notation\n            checkFlags(flagBits, ~GROUP, specifier);\n            allowed = new FloatValidator(specifier);\n          }\n          case 'g', 'G' -> { // scientific notation\n            checkFlags(flagBits, ~ALTERNATE, specifier);\n            allowed = new FloatValidator(specifier);\n          }\n          case 'f' -> // floating point -> decimal number\n            allowed = new FloatValidator(specifier);\n          default -> throw new IllegalFormatException(InspectionGadgetsBundle.message(\"format.string.error.unknown.conversion\", specifier));\n        }\n      }\n      if (precision != null && precision.length() < 2) {\n        throw new IllegalFormatException(InspectionGadgetsBundle.message(\"format.string.error.invalid.precision\", specifier));\n      }\n      if (isAllBitsSet(flagBits, LEADING_SPACE | PLUS)) {\n        throw new IllegalFormatException(\n          InspectionGadgetsBundle.message(\"format.string.error.illegal.flag.combination\", ' ', '+', specifier));\n      }\n      if (isAllBitsSet(flagBits, LEFT_JUSTIFY | ZERO_PAD)) {\n        throw new IllegalFormatException(\n          InspectionGadgetsBundle.message(\"format.string.error.illegal.flag.combination\", '-', '0', specifier));\n      }\n      if (StringUtil.isEmpty(width)) {\n        if (isAllBitsSet(flagBits, LEFT_JUSTIFY)) {\n          throw new IllegalFormatException(InspectionGadgetsBundle.message(\"format.string.error.left.justify.no.width\", specifier));\n        }\n        if (isAllBitsSet(flagBits, ZERO_PAD)) {\n          throw new IllegalFormatException(InspectionGadgetsBundle.message(\"format.string.error.zero.padding.no.width\", specifier));\n        }\n      }\n      storeValidator(allowed, pos, parameters, argumentCount);","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/java-analysis-impl/src/com/siyeh/ig/format/FormatDecode.java#L341-L377","documentation":"IllegalFormatException from FormatDecode when a '.' precision marker is present but has no digits — precision != null && precision.length() < 2 means the captured group is just '.' (the group includes the dot, so valid precisions are '.N' with length >= 2). E.g. '%.f' or '%10.s' is invalid; java.util.Formatter requires at least one digit after '.'.","triggerScenarios":"A specifier like '%.f' or '%5.3' missing digits after the dot in the general case (no conversion-level exemption applied yet); decode() checks this after resolving the validator.","commonSituations":"Typos deleting the precision digit; template placeholders emitting '.' with an empty precision variable; localizing formats where the digit was dropped in translation.","solutions":["Add digits after the precision dot ('%.2f') or remove the dot entirely ('%f')","When generating formats from variables, omit '.' when the precision value is empty"],"exampleFix":"// before\nString.format(\"%.f\", 3.14159)\n// after\nString.format(\"%.2f\", 3.14159)","handlingStrategy":"validation","validationCode":"static boolean precisionWellFormed(String spec) {\n  int dot = spec.indexOf('.');\n  if (dot < 0) return true;\n  return dot + 1 < spec.length() && Character.isDigit(spec.charAt(dot + 1));\n}","typeGuard":null,"tryCatchPattern":"try { FormatDecode.decode(fmt, argc); } catch (IllegalFormatException e) { /* add a digit after '.' or drop the '.' */ }","preventionTips":["Always emit at least one digit after the precision dot","When templating precisions, skip the '.' when the value is empty"],"tags":["intellij","format-string","inspection","java","parsing"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}