{"record":{"id":"a2ff647803255223","repo":"Tyrrrz/DiscordChatExporter","slug":"invalid-partition-limit-value","errorCode":null,"errorMessage":"Invalid partition limit '{value}'.","messagePattern":"Invalid partition limit '(.+?)'\\.","errorType":"validation","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"DiscordChatExporter.Core/Exporting/Partitioning/PartitionLimit.cs","lineNumber":65,"sourceCode":"\n        return (long)(number * magnitude);\n    }\n\n    public static PartitionLimit? TryParse(string value, IFormatProvider? formatProvider = null)\n    {\n        var fileSizeLimit = TryParseFileSizeBytes(value, formatProvider);\n        if (fileSizeLimit is not null)\n            return new FileSizePartitionLimit(fileSizeLimit.Value);\n\n        if (int.TryParse(value, NumberStyles.Integer, formatProvider, out var messageCountLimit))\n            return new MessageCountPartitionLimit(messageCountLimit);\n\n        return null;\n    }\n\n    public static PartitionLimit Parse(string value, IFormatProvider? formatProvider = null) =>\n        TryParse(value, formatProvider)\n        ?? throw new FormatException($\"Invalid partition limit '{value}'.\");\n}\n","sourceCodeStart":47,"sourceCodeEnd":67,"githubUrl":"https://github.com/Tyrrrz/DiscordChatExporter/blob/f6865c82167c3bfee4455da80a1f1ca5e71b95ad/DiscordChatExporter.Core/Exporting/Partitioning/PartitionLimit.cs#L47-L67","documentation":"Thrown as FormatException by PartitionLimit.Parse when TryParse cannot interpret the input as either a file-size expression (e.g. '10mb') or an integer message count. Partitioning splits output into multiple files based on either accumulated byte size or message count; a value matching neither format is rejected. Typically surfaced via CLI binding of the --partition argument.","triggerScenarios":"PartitionLimit.Parse is called with a value that fails TryParseFileSizeBytes AND int.TryParse (PartitionLimit.cs:65). Common at the --partition option when binding CLI args.","commonSituations":"Passing a bare unit without a number ('mb'), a number without a recognized unit ('100x'), a decimal ('1.5mb'), or a typo ('1mbb'); using uppercase or unusual units the size parser does not accept; passing an expression like '100 messages'.","solutions":["Use a file-size form recognized by the parser: a number followed by a unit, e.g. '10mb', '500kb', '1gb'.","Or use a plain integer to partition by message count, e.g. '1000'.","Remove whitespace and avoid thousands separators.","Check TryParseFileSizeBytes' accepted unit tokens if unsure which suffixes are valid."],"exampleFix":"// before\ndotnet run -- exportchat -c <id> -t <token> --partition \"1.5 MB\"\n// after\ndotnet run -- exportchat -c <id> -t <token> --partition 10mb","handlingStrategy":"type-guard","validationCode":"if (PartitionLimit.TryParse(rawPartition, null) is null)\n    throw new ArgumentException($\"'{rawPartition}' is not a valid partition limit (use '10mb' or '1000').\");","typeGuard":"static PartitionLimit? TryPartition(string? s) =>\n    string.IsNullOrWhiteSpace(s) ? null : PartitionLimit.TryParse(s, CultureInfo.InvariantCulture);","tryCatchPattern":"try { var limit = PartitionLimit.Parse(rawPartition); }\ncatch (FormatException) { logger.LogWarning(\"Bad partition '{Raw}'; falling back to no partitioning\", rawPartition); limit = null; }","preventionTips":["Use a plain integer (message count) or number+unit (size) format.","Validate at the CLI boundary with TryParse before binding.","Avoid decimals, thousands separators, and unknown unit suffixes."],"tags":["parsing","partitioning","cli","configuration"],"backgroundTag":null,"analyzedSha":"f6865c82167c3bfee4455da80a1f1ca5e71b95ad","analyzedAt":"2026-08-13T18:08:46.403Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}