{"record":{"id":"478b20884053d508","repo":"microsoft/garnet","slug":"invalid-character-c-in-aofaddress-string","errorCode":null,"errorMessage":"Invalid character '{c}' in AofAddress string.","messagePattern":"Invalid character '(.+?)' in AofAddress string\\.","errorType":"validation","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"libs/server/AOF/AofAddress.cs","lineNumber":181,"sourceCode":"            for (var i = 0; i < span.Length; i++)\n            {\n                var c = span[i];\n                if (c == ',')\n                {\n                    aofAddress[idx++] = value;\n                    value = 0;\n                }\n                else if (c >= '0' && c <= '9')\n                {\n                    value = value * 10 + (c - '0');\n                }\n                else if (c == '-')\n                {\n                    negative = true;\n                }\n                else\n                {\n                    throw new FormatException($\"Invalid character '{c}' in AofAddress string.\");\n                }\n            }\n\n            // Handle last value\n            aofAddress[idx] = value * (negative ? -1 : 1);\n            return aofAddress;\n        }\n\n        /// <summary>\n        /// Serialize contents using provided BinaryWriter\n        /// </summary>\n        /// <param name=\"writer\"></param>\n        public void Serialize(BinaryWriter writer)\n        {\n            writer.Write(length);\n            for (var i = 0; i < Length; i++)\n                writer.Write(addresses[i]);\n        }","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/AOF/AofAddress.cs#L163-L199","documentation":"Thrown by AofAddress.FromString(input) when parsing a comma-separated list of decimal integers and encountering a character that is not a digit (0-9), a comma separator, or a minus sign. This is a standard System.FormatException indicating the input string does not conform to the expected address-list grammar.","triggerScenarios":"Calling AofAddress.FromString with input like \"100;200\" (semicolon), \"100.5\" (decimal point), \"0x100\" (hex), \"100 200\" (space), or any string containing letters, whitespace, or punctuation other than ',' and '-'. The parser only accepts integer literals and '-' for negative values.","commonSituations":"Deserializing a user-supplied or config-supplied AOF address string with the wrong delimiter; copy-pasting an address representation from a different format; locale-specific number formatting leaking in.","solutions":["Ensure the input string contains only digits, commas, and optional minus signs (e.g. \"100,200,-1\").","Pre-validate with a regex such as ^-?\\d+(,-?\\d+)*$ before calling FromString.","If the input comes from a config file, document the expected format explicitly."],"exampleFix":"// before\nvar addr = AofAddress.FromString(\"100; 200; 300\");\n\n// after\nvar addr = AofAddress.FromString(\"100,200,300\");","handlingStrategy":"validation","validationCode":"using System.Text.RegularExpressions;\nif (!Regex.IsMatch(input, @\"^-?\\d+(,-?\\d+)*$\"))\n    throw new FormatException($\"Input '{input}' is not a valid comma-separated integer list.\");","typeGuard":"static bool IsValidAofAddressString(string input) =>\n    !string.IsNullOrEmpty(input) &&\n    Regex.IsMatch(input, @\"^-?\\d+(,-?\\d+)*$\");","tryCatchPattern":"try { var addr = AofAddress.FromString(input); }\ncatch (FormatException ex) { logger.LogError(\"Invalid AofAddress input: {Msg}\", ex.Message); throw; }","preventionTips":["Validate address strings with a comma-separated-integer regex before parsing.","Document the exact accepted format (digits, commas, minus) for config consumers.","Reject locale-specific formatting early."],"tags":["aof","parsing","validation"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}