{"record":{"id":"c7e139e15653707b","repo":"bazelbuild/bazel","slug":"not-all-arguments-converted-during-string-formatti","errorCode":null,"errorMessage":"not all arguments converted during string formatting","messagePattern":"not all arguments converted during string formatting","errorType":"exception","errorClass":"MissingFormatWidthException","httpStatus":null,"severity":"error","filePath":"src/main/java/net/starlark/java/eval/Printer.java","lineNumber":476,"sourceCode":"              };\n          printer.append(StarlarkFloat.format(v, conv));\n        }\n\n        case 'r' -> printer.repr(arg, semantics);\n\n        case 's' -> printer.str(arg, semantics);\n\n        default ->\n            // The call to Starlark.repr doesn't cause an infinite recursion\n            // because it's only used to format a string properly.\n            throw new MissingFormatWidthException(\n                String.format(\n                    \"unsupported format character \\\"%s\\\" at index %s in %s\",\n                    conv, p + 1, Starlark.repr(pattern, semantics)));\n      }\n    }\n    if (a < argLength) {\n      throw new MissingFormatWidthException(\"not all arguments converted during string formatting\");\n    }\n  }\n}\n","sourceCodeStart":458,"sourceCodeEnd":480,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/net/starlark/java/eval/Printer.java#L458-L480","documentation":"Thrown by %-formatting at the end of the pattern when some arguments were never consumed — the argument index a is still below argLength after the whole pattern was scanned. Starlark's % operator (unlike modern Python % with mapping patterns) requires that every argument be used by exactly one conversion.","triggerScenarios":"\"%s\" % (1, 2), \"hello %s\" % (name, extra), or passing a tuple/list where a single element value was intended (\"%s\" % [x] works since the list is one arg, but \"%s\" % (x, y) fails).","commonSituations":"Removing a field from a message template but keeping its argument; building an args tuple dynamically and over-supplying; misunderstanding that a single value need not be a tuple: \"%s\" % x is fine.","solutions":["Delete the unused arguments or add the corresponding %s fields to consume them.","Pass exactly one value (not a tuple) when the pattern has one field: \"msg: %s\" % x.","For dynamic tuples, build the pattern and args together (e.g. \" \".join([\"%s\"] * len(args)))."],"exampleFix":"# before\n\"user %s\" % (user, timestamp)\n\n# after\n\"user %s at %s\" % (user, timestamp)","handlingStrategy":"validation","validationCode":"args = (a,) if not hasattr(a, \"__len__\") else a  # ensure tuple shape matches field count\n# and ensure len(args) == number of %s fields (see error 108 counter)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Every argument must be consumed by a conversion; delete extras or add fields.","Build pattern and args together for dynamic messages: ' '.join(['%s'] * len(args)) % tuple(args)."],"tags":["starlark","format","percent-format","arguments"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}