{"record":{"id":"b96b351977b82ad4","repo":"Humanizr/Humanizer","slug":"input-words-cannot-be-empty-b96b35","errorCode":null,"errorMessage":"Input words cannot be empty.","messagePattern":"Input words cannot be empty\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Humanizer/Localisation/WordsToNumber/InvertedTensWordsToNumberConverter.cs","lineNumber":38,"sourceCode":"    {\n        if (!TryConvert(words, out var parsedValue, out var unrecognizedWord))\n        {\n            throw new ArgumentException($\"Unrecognized number word: {unrecognizedWord}\");\n        }\n\n        return parsedValue;\n    }\n\n    /// <inheritdoc />\n    public override bool TryConvert(string words, out long parsedValue) =>\n        TryConvert(words, out parsedValue, out _);\n\n    /// <inheritdoc />\n    public override bool TryConvert(string words, out long parsedValue, out string? unrecognizedWord)\n    {\n        if (string.IsNullOrWhiteSpace(words))\n        {\n            throw new ArgumentException(\"Input words cannot be empty.\");\n        }\n\n        var normalized = Normalize(words);\n        var negative = false;\n\n        foreach (var negativePrefix in profile.NegativePrefixes)\n        {\n            if (!normalized.StartsWith(negativePrefix, StringComparison.Ordinal))\n            {\n                continue;\n            }\n\n            negative = true;\n            normalized = normalized[negativePrefix.Length..].Trim();\n            break;\n        }\n\n        if (profile.AllowInvariantIntegerInput &&","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer/Localisation/WordsToNumber/InvertedTensWordsToNumberConverter.cs#L20-L56","documentation":"This ArgumentException is thrown inside InvertedTensWordsToNumberConverter.TryConvert when the input is null, empty, or whitespace. It throws from the Try-variant, so TryToNumber will throw rather than return false on blank input. The inverted-tens parser needs at least one token to attempt structural decomposition.","triggerScenarios":"Calling ToNumber or TryToNumber with null, string.Empty, or whitespace on a locale backed by InvertedTensWordsToNumberConverter.","commonSituations":"Blank user input; deserialized payloads with missing fields; strings that became empty after trimming; nullable reference not checked before the call.","solutions":["Check string.IsNullOrWhiteSpace(words) before calling either API.","Return a default or handle the empty case at the call site.","Enable nullable reference types for compile-time null safety."],"exampleFix":"// before\nlong value = input.ToNumber(culture);\n\n// after\nif (string.IsNullOrWhiteSpace(input))\n    return 0;\nlong value = input.ToNumber(culture);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(words))\n    return 0;\nreturn words.ToNumber(culture);","typeGuard":"static bool IsNonEmpty(string? words) =>\n    !string.IsNullOrWhiteSpace(words);","tryCatchPattern":"// TryToNumber also throws on empty — guard before calling\ntry\n{\n    return words.ToNumber(culture);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"cannot be empty\"))\n{\n    return 0;\n}","preventionTips":["Always guard with string.IsNullOrWhiteSpace before calling ToNumber or TryToNumber.","Handle blank input as a business decision at the call site.","Enable nullable reference types for compile-time null safety.","Validate at trust boundaries before data reaches the parser."],"tags":["argumentexception","words-to-number","inverted-tens","null-empty-input","validation"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}