{"record":{"id":"5a4a3d3bd23f1f31","repo":"Humanizr/Humanizer","slug":"subject-references-unknown-source-source","errorCode":null,"errorMessage":"{subject} references unknown source '{source}'.","messagePattern":"(.+?) references unknown source '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogValidation.cs","lineNumber":103,"sourceCode":"            var correct = GetRequiredInt(values, \"correct\", $\"Productive evidence '{direction}' must define correct\");\n            if (attempted < 100 || correct < 0 || correct > attempted ||\n                correct * 100L < attempted * 99L)\n            {\n                throw new InvalidOperationException(\n                    $\"Productive evidence '{direction}' requires at least 100 attempts and 99% correctness.\");\n            }\n        }\n\n        static void ValidateSources(\n            SimpleYamlMapping mapping,\n            ImmutableHashSet<string> sourceIds,\n            string subject)\n        {\n            foreach (var source in GetRequiredStrings(mapping, \"sources\", $\"{subject} must define sources\"))\n            {\n                if (!sourceIds.Contains(source))\n                {\n                    throw new InvalidOperationException($\"{subject} references unknown source '{source}'.\");\n                }\n            }\n        }\n\n        static void ValidateSourceDefinitions(SimpleYamlMapping sources)\n        {\n            foreach (var entry in sources.Values)\n            {\n                if (entry.Value is not SimpleYamlMapping source ||\n                    source.GetScalar(\"kind\") is not { Length: > 0 } ||\n                    source.GetScalar(\"locator\") is not { Length: > 0 })\n                {\n                    throw new InvalidOperationException(\n                        $\"Inflection source '{entry.Key}' must define non-empty kind and locator.\");\n                }\n\n                ValidateProperties(\n                    source,","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogValidation.cs#L85-L121","documentation":"Every source ID referenced in an evidence block's 'sources:' list must be declared in the inflection catalog's top-level source definitions. This validator walks the sources array and rejects any ID not present in the known sourceIds set, preventing evidence from pointing at nonexistent provenance records.","triggerScenarios":"An evidence block (or any ValidateSources caller) lists a source string that does not match any key in the catalog's 'sources:' mapping. For example, evidence references 'ud2.15' but the sources section only defines 'ud2.14'.","commonSituations":"Renaming a source ID without updating all references. Copying an evidence block from another locale and forgetting to add the corresponding source definition. Typo in the source ID.","solutions":["Add a matching source definition entry under the catalog's 'sources:' mapping with the referenced ID, including kind and locator.","Fix the typo in the evidence 'sources:' list to match an existing source ID exactly.","Remove the orphaned source reference from the evidence block if the source is no longer relevant."],"exampleFix":"# before\nsources:\n  ud274:\n    kind: 'treebank'\n    locator: '...'\nevidence:\n  pluralize:\n    sources: ['ud275']\n# after\nsources:\n  ud274:\n    kind: 'treebank'\n    locator: '...'\nevidence:\n  pluralize:\n    sources: ['ud274']","handlingStrategy":"validation","validationCode":"# Before building, verify every referenced source ID exists in the sources mapping.\npython3 -c \"\nimport yaml, sys\nfor f in sys.argv[1:]:\n    d = yaml.safe_load(open(f))\n    infl = d.get('inflection',{})\n    declared = set((infl.get('sources') or {}).keys())\n    ev = infl.get('evidence',{})\n    for direction in ('pluralize','singularize'):\n        for src in (ev.get(direction,{}).get('sources') or []):\n            if src not in declared:\n                print(f'{f}: evidence {direction} references unknown source {src!r}')\n\" src/Humanizer/Locales/*.yml","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Maintain a single canonical source ID vocabulary and cross-reference it when editing evidence blocks.","When renaming a source ID, search-and-replace across all locale files to update references.","Add a pre-build CI step that validates source references against declared source definitions."],"tags":["inflection","source-generator","sources","provenance","yaml","build-time"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}