OrchardCMS/OrchardCore · error · ArgumentOutOfRangeException

Unsupported Azure AI Search vector algorithm kind.

Error message

Unsupported Azure AI Search vector algorithm kind.

What it means

CreateVectorSearchAlgorithm maps the configured algorithm Kind to the Azure SDK's VectorSearchAlgorithm; when the metadata contains a Kind value outside the supported set, this ArgumentOutOfRangeException is thrown. It is an internal invariant check against unexpected enum values persisted in index metadata.

Solutions

  1. Open the index profile and re-select a supported vector algorithm (Hnsw or ExhaustiveKnn)
  2. Fix the algorithm Kind value in the stored AzureAISearchIndexMetadata
  3. Re-create the index profile with a valid algorithm configuration

Example fix

// before
"algorithm": { "kind": "DiskANN" }
// after
"algorithm": { "kind": "Hnsw" }
Defensive patterns

Strategy: validation

Validate before calling

var valid = new[] { "hnsw", "exhaustiveKnn" }; var ok = valid.Contains(config.Kind, StringComparer.OrdinalIgnoreCase);

Type guard

bool isValidKind = Enum.IsDefined(typeof(AzureAISearchVectorAlgorithmKind), config.Kind);

Try / catch

try { await EnsureAlgorithm(index); } catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "algorithm") { /* reconfigure algorithm kind */ }

Prevention

When it happens

Trigger: Calling EnsureAlgorithm/CreateVectorSearchAlgorithm with an AzureAISearchVectorAlgorithmConfig whose Kind is neither Hnsw nor ExhaustiveKnn (e.g., stale or hand-edited metadata).

Common situations: Index metadata written by an older module version; JSON metadata manually edited with an invalid kind; future enum values from newer versions read by older code.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/3c9e546c2cb15007. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore/OrchardCore.AzureAI.Core/Services/AzureAISearchIndexManager.cs:343

            return hnswConfiguration;
        }

        if (algorithm.Kind.EqualsOrdinalIgnoreCase(VectorSearchAlgorithmMap.ExhaustiveKnnKind))
        {
            var exhaustiveKnnConfiguration = new ExhaustiveKnnAlgorithmConfiguration(algorithm.Name);

            if (algorithm.ExhaustiveKnnParametersMap is not null)
            {
                exhaustiveKnnConfiguration.Parameters = new ExhaustiveKnnParameters
                {
                    Metric = ToVectorSearchAlgorithmMetric(algorithm.ExhaustiveKnnParametersMap.Metric),
                };
            }

            return exhaustiveKnnConfiguration;
        }

        throw new ArgumentOutOfRangeException(nameof(algorithm), algorithm.Kind, "Unsupported Azure AI Search vector algorithm kind.");
    }

    private static VectorSearchAlgorithmMetric? ToVectorSearchAlgorithmMetric(string metric)
        => string.IsNullOrWhiteSpace(metric) ? null : new VectorSearchAlgorithmMetric(metric);

    private static string GetVectorSearchProfileName(AzureAISearchIndexMetadata metadata, AzureAISearchIndexMapVectorInfo vectorInfo)
    {
        if (!string.IsNullOrWhiteSpace(vectorInfo?.VectorSearchConfiguration))
        {
            return vectorInfo.VectorSearchConfiguration;
        }

        var configuredProfileName = GetConfiguredProfiles(metadata.VectorSearchMappings).FirstOrDefault()?.Name;

        return string.IsNullOrWhiteSpace(configuredProfileName)
            ? VectorSearchMappings.DefaultProfileName
            : configuredProfileName;
    }

View on GitHub (pinned to 4306c0717f)