{"record":{"id":"f2b9b32afd3f4b99","repo":"Humanizr/Humanizer","slug":"template-path-must-define-a-scalar-value","errorCode":null,"errorMessage":"Template '{path}' must define a scalar 'value'.","messagePattern":"Template '(.+?)' must define a scalar 'value'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/LocalePhraseNormalization.cs","lineNumber":432,"sourceCode":"                null or \"\" or \"before-form\" or \"before\" => CountPlacement.BeforeForm,\n                \"after-form\" or \"after\" => CountPlacement.AfterForm,\n                \"none\" => CountPlacement.None,\n                var value => throw new InvalidOperationException($\"Phrase '{path}.countPlacement' uses unsupported count placement '{value}'.\")\n            };\n\n        static NamedTemplatePhrase ParseNamedTemplate(SimpleYamlValue value, string path, params string[] allowedPlaceholders)\n        {\n            if (value is SimpleYamlScalar scalar)\n            {\n                return CreateNamedTemplatePhrase(null, scalar.Value, path, allowedPlaceholders);\n            }\n\n            var mapping = ExpectMapping(value, path);\n            RejectUnknownKeys(mapping, path, [\"name\", \"value\"]);\n            var name = GetOptionalLiteral(mapping, \"name\", $\"{path}.name\");\n            if (!mapping.TryGetValue(\"value\", out var templateValue) || templateValue is not SimpleYamlScalar templateScalar)\n            {\n                throw new InvalidOperationException($\"Template '{path}' must define a scalar 'value'.\");\n            }\n\n            return CreateNamedTemplatePhrase(name, templateScalar.Value, path, allowedPlaceholders);\n        }\n\n        static NamedTemplatePhrase CreateNamedTemplatePhrase(string? templateName, string template, string path, params string[] allowedPlaceholders)\n        {\n            var placeholders = ImmutableArray.CreateBuilder<string>();\n\n            foreach (var placeholderName in GetPlaceholderNames(template))\n            {\n                if (int.TryParse(placeholderName, out _))\n                {\n                    throw new InvalidOperationException($\"Template '{path}' cannot use numeric placeholder '{{{placeholderName}}}'.\");\n                }\n\n                if (placeholderName.Length == 0 || !char.IsLetter(placeholderName[0]) || placeholderName.Any(static c => !char.IsLetterOrDigit(c) && c != '_'))\n                {","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/LocalePhraseNormalization.cs#L414-L450","documentation":"Thrown by ParseNamedTemplate when a 'template' entry is a mapping but either lacks a 'value' key or its value is not a scalar. Templates require a scalar 'value' string (optionally with a 'name'). Surfaced as compiler diagnostic HSG003 (severity Error).","triggerScenarios":"Authoring template: { name: ... } with no value; making the value a mapping/sequence; misspelling 'value' as 'Value' or 'text'.","commonSituations":"Authoring a named template and forgetting the value field; YAML indentation making value a child of the wrong key; copy-paste from a doc snippet that omitted value.","solutions":["Add a scalar 'value' string to the template mapping (e.g. value: '{count} {unit}').","If no name is needed, write the template as a plain scalar (template: '{count} {unit}').","Rebuild to confirm the diagnostic clears."],"exampleFix":"# before\ntemplate:\n  name: age\n# after\ntemplate:\n  name: age\n  value: '{count} {unit} ago'","handlingStrategy":"validation","validationCode":"# Any template that is a mapping must contain a scalar 'value'.\nyq -o=json '.. | select(has(\"template\")) | .template | select(tag == \"!!map\" and (has(\"value\") | not))' src/Humanizer/Locales/<code>.yml","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default to scalar templates (template: '{count} {unit}') unless you need a name.","When using a mapping, add 'value' first.","Build after authoring templates."],"tags":["humanizer","source-generator","locale","yaml","localization","phrases","template"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}