{"record":{"id":"588c5cfb2ba138e4","repo":"AvaloniaUI/Avalonia","slug":"bad-format-specifier","errorCode":null,"errorMessage":"Bad format specifier.","messagePattern":"Bad format specifier\\.","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Collections/Pooled/ThrowHelper.cs","lineNumber":336,"sourceCode":"            throw new InvalidOperationException(\"No value provided.\");\n        }\n\n        [DoesNotReturn]\n        internal static void ThrowInvalidOperationException_ConcurrentOperationsNotSupported()\n        {\n            throw new InvalidOperationException(\"Concurrent operations are not supported.\");\n        }\n\n        [DoesNotReturn]\n        internal static void ThrowInvalidOperationException_HandleIsNotInitialized()\n        {\n            throw new InvalidOperationException(\"Handle is not initialized.\");\n        }\n\n        [DoesNotReturn]\n        internal static void ThrowFormatException_BadFormatSpecifier()\n        {\n            throw new FormatException(\"Bad format specifier.\");\n        }\n\n        private static ArgumentException GetArgumentException(ExceptionResource resource)\n        {\n            return new ArgumentException(GetResourceString(resource));\n        }\n\n        private static InvalidOperationException GetInvalidOperationException(ExceptionResource resource)\n        {\n            return new InvalidOperationException(GetResourceString(resource));\n        }\n\n        private static ArgumentException GetWrongKeyTypeArgumentException(object? key, Type targetType)\n        {\n            return new ArgumentException($\"Wrong key type. Expected {targetType}, got: '{key}'.\", nameof(key));\n        }\n\n        private static ArgumentException GetWrongValueTypeArgumentException(object? value, Type targetType)","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Collections/Pooled/ThrowHelper.cs#L318-L354","documentation":"Thrown by ThrowFormatException_BadFormatSpecifier() in the Pooled collections ThrowHelper. This is a reserved/internal throw helper for malformed format specifiers during string formatting inside the pooled-array utilities. In the current Avalonia codebase this helper has no call sites — it is vestigial dead code ported from .NET's internal collections, so it is effectively unreachable through any public API.","triggerScenarios":"Only reachable if a future change wires ThrowFormatException_BadFormatSpecifier() into a format-parsing path in the Pooled collections. Today there is no caller; searching the entire repo returns only the definition at ThrowHelper.cs:334.","commonSituations":"You will not encounter this in normal Avalonia development. If you do see it, a custom fork or unreleased build added a format-string parser that delegates to this helper and was passed an invalid specifier token.","solutions":["Confirm the exception originates from Avalonia.Base Pooled code and not your own FormatException; check the full stack trace for the actual caller.","If it appears in a fork, audit any new format-parsing code that calls ThrowFormatException_BadFormatSpecifier and validate the specifier before calling.","In a stock build this should never fire — file an issue against Avalonia if it does, including the stack trace."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// No public caller exists; if you maintain a fork that wires this helper,\n// validate the format specifier before delegating to it.\nif (!IsValidSpecifier(token)) return;","typeGuard":null,"tryCatchPattern":"try { /* format-parsing path in forked pooled code */ }\ncatch (FormatException ex) when (ex.Message == \"Bad format specifier.\")\n{\n    // log and fall back to default formatting\n}","preventionTips":["In stock Avalonia this is unreachable — treat any sighting as a signal of a custom/forked build and audit new format-parsing code.","Keep ThrowHelper throw helpers wired only behind validated parsing entry points."],"tags":["pooled-collections","format","dead-code","internal"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}