{"record":{"id":"301bbe2c9c7b6fd5","repo":"spectreconsole/spectre.console","slug":"profile-enricher-of-type-enricher-gettype-full","errorCode":null,"errorMessage":"Profile enricher of type '{enricher.GetType().FullName}' does not have a name.","messagePattern":"Profile enricher of type '(.+?)' does not have a name\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console/Enrichment/ProfileEnricher.cs","lineNumber":37,"sourceCode":"        new TfsEnricher(),\n        new TravisEnricher()\n    ];\n\n    public static void Enrich(\n        Profile profile,\n        ProfileEnrichment settings,\n        IDictionary<string, string>? environmentVariables)\n    {\n        ArgumentNullException.ThrowIfNull(profile);\n\n        settings ??= new ProfileEnrichment();\n\n        var variables = GetEnvironmentVariables(environmentVariables);\n        foreach (var enricher in GetEnrichers(settings))\n        {\n            if (string.IsNullOrWhiteSpace(enricher.Name))\n            {\n                throw new InvalidOperationException($\"Profile enricher of type '{enricher.GetType().FullName}' does not have a name.\");\n            }\n\n            if (enricher.Enabled(variables))\n            {\n                enricher.Enrich(profile);\n                profile.AddEnricher(enricher.Name);\n            }\n        }\n    }\n\n    private static List<IProfileEnricher> GetEnrichers(ProfileEnrichment settings)\n    {\n        var enrichers = new List<IProfileEnricher>();\n\n        if (settings.UseDefaultEnrichers)\n        {\n            enrichers.AddRange(_defaultEnrichers);\n        }","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console/Enrichment/ProfileEnricher.cs#L19-L55","documentation":"Thrown by ProfileEnricher.Enrich when an IProfileEnricher in the configured set has a Name that is null, empty, or whitespace. Names are used to record which enrichers applied to a profile (profile.AddEnricher), so an unnamed enricher is invalid. This guards both built-in and user-supplied enrichers.","triggerScenarios":"Registering a custom IProfileEnricher whose Name property returns null/\"\"/whitespace, and including it in the ProfileEnrichment set used at console creation.","commonSituations":"Third-party or hand-written enricher that forgot to implement Name; an enricher whose Name is computed from missing config; copy of a built-in enricher with the name overridden to empty.","solutions":["Give your custom IProfileEnricher a stable non-empty Name property","If you do not need a custom enricher, remove it from settings.Enrichment","Audit third-party enrichers for a non-empty Name before registration"],"exampleFix":"// before\npublic sealed class MyEnricher : IProfileEnricher\n{\n    public string Name => \"\"; // throws\n    public void Enrich(Profile p) { }\n}\n\n// after\npublic sealed class MyEnricher : IProfileEnricher\n{\n    public string Name => \"my-enricher\";\n    public void Enrich(Profile p) { }\n}","handlingStrategy":"validation","validationCode":"// Validate a custom enricher's Name before registration\nforeach (var e in myEnrichers)\n{\n    if (string.IsNullOrWhiteSpace(e.Name))\n        throw new InvalidOperationException($\"Enricher {e.GetType().FullName} has no name\");\n}","typeGuard":"static bool HasValidName(IProfileEnricher e) => !string.IsNullOrWhiteSpace(e.Name);","tryCatchPattern":"try\n{\n    // creation triggers ProfileEnricher.Enrich\n    var console = AnsiConsole.Create(settings);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"does not have a name\"))\n{\n    // a registered enricher returned an empty Name\n}","preventionTips":["Always implement a stable, non-empty Name on custom IProfileEnricher","Audit third-party enrichers for a valid Name before registration","Cover enricher Name in unit tests"],"tags":["enricher","profile","configuration","null-check"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}