{"record":{"id":"731d215d63055040","repo":"OrchardCMS/OrchardCore","slug":"both-the-index-name-and-index-full-name-must-be-set","errorCode":null,"errorMessage":"Both the index-name and index full-name must be set.","messagePattern":"Both the index-name and index full-name must be set\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.Indexing.Core/Handlers/DefaultIndexProfileHandler.cs","lineNumber":132,"sourceCode":"                {\n                    context.Result.Fail(new ValidationResult(S[\"The index full name is required. Unable to find a index name provider that with the provider name '{0}'.\", context.Model.ProviderName, context.Model.Type], [nameof(IndexProfile.Type)]));\n                }\n                else\n                {\n                    // Set the full name of the index.\n                    context.Model.IndexFullName = nameProvider.GetFullIndexName(context.Model.IndexName);\n                }\n            }\n        }\n    }\n\n    public override Task CreatingAsync(CreatingContext<IndexProfile> context)\n    {\n        SetIndexFullName(context.Model);\n\n        if (string.IsNullOrEmpty(context.Model.IndexName) || string.IsNullOrEmpty(context.Model.IndexFullName))\n        {\n            throw new InvalidOperationException(\"Both the index-name and index full-name must be set.\");\n        }\n\n        return Task.CompletedTask;\n    }\n\n    public override Task InitializedAsync(InitializedContext<IndexProfile> context)\n    {\n        context.Model.CreatedUtc = _clock.UtcNow;\n        var user = _httpContextAccessor.HttpContext?.User;\n\n        if (user != null)\n        {\n            context.Model.OwnerId = user.FindFirstValue(ClaimTypes.NameIdentifier);\n            context.Model.Author = user.Identity.Name;\n        }\n\n        return Task.CompletedTask;\n    }","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Indexing.Core/Handlers/DefaultIndexProfileHandler.cs#L114-L150","documentation":"DefaultIndexProfileHandler.CreatingAsync calls SetIndexFullName to derive IndexName and IndexFullName from the profile, then validates both are non-empty. If the handler could not derive them, it throws InvalidOperationException to stop creation of an unusable index profile.","triggerScenarios":"Creating an IndexProfile (via IIndexProfileManager.CreateAsync or the admin UI) whose descriptor/type does not populate IndexName, so SetIndexFullName cannot compute IndexName/IndexFullName.","commonSituations":"Custom index profile types (e.g. new search providers) missing the naming setup; recipes or import code creating profiles with empty names; version changes where provider defaults were dropped.","solutions":["Ensure the profile's provider sets IndexName before creation completes (implement provider-specific naming defaults).","Pass a non-empty name when creating the profile via IIndexProfileManager.NewAsync(provider, name).","Fix recipe/import JSON so the index profile 'Name' field is present."],"exampleFix":"// before\nvar profile = await indexProfileManager.NewAsync(\"Lucene\");\nawait indexProfileManager.CreateAsync(profile); // IndexName empty\n// after\nvar profile = await indexProfileManager.NewAsync(\"Lucene\", \"MySearchIndex\");\nawait indexProfileManager.CreateAsync(profile);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(profile.IndexName) || string.IsNullOrEmpty(profile.IndexFullName))\n    throw new ArgumentException(\"IndexName and IndexFullName must be set before creating the profile.\");","typeGuard":null,"tryCatchPattern":"try { await manager.CreateAsync(profile); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"index-name\")) { /* prompt user for a name */ }","preventionTips":["Always supply a name via NewAsync(provider, name)","Implement provider default naming for custom profile types","Validate recipe JSON index profile entries during authoring"],"tags":["indexing","validation","empty-required-field","missing-required-argument"],"backgroundTag":"missing-required-config-field","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}