{"record":{"id":"e9a324548699e272","repo":"Humanizr/Humanizer","slug":"missing-required-property-propertyname","errorCode":null,"errorMessage":"Missing required property '{propertyName}'.","messagePattern":"Missing required property '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/GenerationHelpers.cs","lineNumber":189,"sourceCode":"    static string ToEnumMemberName(string value)\n    {\n        var segments = value.Split(['-', '_'], StringSplitOptions.RemoveEmptyEntries);\n        var builder = new StringBuilder(value.Length);\n\n        foreach (var lower in segments.Select(static segment => segment.ToLowerInvariant()))\n        {\n            builder.Append(char.ToUpperInvariant(lower[0]));\n            if (lower.Length > 1)\n            {\n                builder.Append(lower, 1, lower.Length - 1);\n            }\n        }\n\n        return builder.ToString();\n    }\n\n    static string GetRequiredString(JsonElement element, string propertyName) =>\n        GetOptionalString(element, propertyName) ?? throw new InvalidOperationException($\"Missing required property '{propertyName}'.\");\n\n    static string? GetOptionalString(JsonElement element, string propertyName) =>\n        element.TryGetProperty(propertyName, out var property) && property.ValueKind == JsonValueKind.String\n            ? property.GetString()\n            : null;\n\n    static string? GetExplicitDurationCaseNumberDetector(ResolvedLocaleDefinition locale)\n    {\n        if (locale.Formatter is not { } formatter)\n        {\n            return null;\n        }\n\n        return GetOptionalString(formatter.ProfileRoot, \"casePluralRule\");\n    }\n\n    static string? GetDurationCaseNumberDetector(ResolvedLocaleDefinition locale)\n    {","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/GenerationHelpers.cs#L171-L207","documentation":"GenerationHelpers.GetRequiredString (GenerationHelpers.cs:188-189) returns a mandatory string property and throws when it is absent OR present but not a JSON string. Callers include duration-case number-detector resolution (GetDurationCaseNumberDetector reads pluralRule/resourceKeyDetector from a formatter profile). Both absence and a type mismatch (number/bool/object where a string is expected) surface as this same message.","triggerScenarios":"A JSON element used during generation is missing a required string field, or the field holds a non-string JSON value (e.g. a number or boolean).","commonSituations":"A formatter profile lacks pluralRule/resourceKeyDetector; a locale JSON value was changed from a quoted string to an unquoted number; a required field renamed upstream.","solutions":["Add the missing property as a JSON string value.","If the value exists but is a number/bool, quote it so it becomes a JSON string.","Verify against the contract/profile schema which fields are required strings for this generator path."],"exampleFix":"// before\n{ \"pluralRule\": 1 }\n// after\n{ \"pluralRule\": \"one\" }","handlingStrategy":"validation","validationCode":"// Required string must exist AND be a string (C#)\nstatic string RequireString(JsonElement el, string name) {\n    if (!el.TryGetProperty(name, out var p) || p.ValueKind != JsonValueKind.String)\n        throw new InvalidOperationException($\"Missing/non-string required property '{name}'\");\n    return p.GetString()!;\n}","typeGuard":"static bool IsStringProperty(JsonElement el, string name) =>\n    el.TryGetProperty(name, out var p) && p.ValueKind == JsonValueKind.String;","tryCatchPattern":null,"preventionTips":["Quote string values in locale JSON/YAML so they parse as strings, not numbers.","Keep a list of required string fields per profile (e.g. pluralRule, resourceKeyDetector).","Validate profile JSON against a schema that types these fields as string."],"tags":["source-generator","build-time","engine-contract","json","localization","locale-data"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}