microsoft/semantic-kernel · error · ArgumentException

The option keys 'asset_identifiers' and 'asset_type' are req

Error message

The option keys 'asset_identifiers' and 'asset_type' are required for a vector store data source.

What it means

Thrown while building vector store data sources (CreateDataSources). Each data source dictionary must contain a non-empty 'asset_identifier' string and a non-empty 'asset_type' string; both are needed to construct a VectorStoreDataSource. Missing or empty either one throws ArgumentException.

Source

Thrown at dotnet/src/Agents/AzureAI/Extensions/AgentToolDefinitionExtensions.cs:136

    internal static List<VectorStoreDataSource>? GetDataSources(this AgentToolDefinition agentToolDefinition)
    {
        var dataSources = agentToolDefinition.GetOption<List<object>?>("data_sources");
        return dataSources is not null ? CreateDataSources(dataSources) : null;
    }

    internal static List<VectorStoreDataSource> CreateDataSources(List<object> values)
    {
        List<VectorStoreDataSource> dataSources = [];
        foreach (var value in values)
        {
            if (value is Dictionary<object, object> dataSourceDict)
            {
                string? assetIdentifier = dataSourceDict.TryGetValue("asset_identifier", out var identifierValue) && identifierValue is string identifierString ? identifierString : null;
                string? assetType = dataSourceDict.TryGetValue("asset_type", out var typeValue) && typeValue is string typeString ? typeString : null;

                if (string.IsNullOrEmpty(assetIdentifier) || string.IsNullOrEmpty(assetType))
                {
                    throw new ArgumentException("The option keys 'asset_identifier' and 'asset_type' are required for a vector store data source.");
                }

                dataSources.Add(new VectorStoreDataSource(assetIdentifier, new VectorStoreDataSourceAssetType(assetType)));
            }
        }

        return dataSources;
    }

    internal static IList<VectorStoreConfigurations>? GetVectorStoreConfigurations(this AgentToolDefinition agentToolDefinition)
    {
        var dataSources = agentToolDefinition.GetOption<List<object>?>("configurations");
        return dataSources is not null ? CreateVectorStoreConfigurations(dataSources) : null;
    }

    internal static List<VectorStoreConfigurations> CreateVectorStoreConfigurations(List<object> values)
    {
        List<VectorStoreConfigurations> configurations = [];

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Provide both 'asset_identifier' (string) and 'asset_type' (string) for every data source entry.
  2. Use a valid asset_type value recognized by VectorStoreDataSourceAssetType.

Example fix

// before
data_sources:
  - asset_identifier: 'file-abc123'
    # asset_type missing -> throws 163

// after
data_sources:
  - asset_identifier: 'file-abc123'
    asset_type: 'azure_blob_storage'
Defensive patterns

Strategy: validation

Validate before calling

foreach (var v in values)
{
    if (v is not Dictionary<object, object> d) continue;
    string? id = d.TryGetValue("asset_identifier", out var i) && i is string s1 ? s1 : null;
    string? type = d.TryGetValue("asset_type", out var t) && t is string s2 ? s2 : null;
    if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(type))
        throw new ArgumentException("Each data source needs asset_identifier and asset_type.");
}

Type guard

static bool IsValidDataSource(Dictionary<object, object> d) =>
    d.TryGetValue("asset_identifier", out var i) && i is string si && !string.IsNullOrEmpty(si)
    && d.TryGetValue("asset_type", out var t) && t is string st && !string.IsNullOrEmpty(st);

Prevention

When it happens

Trigger: A vector store data source entry in tool options has asset_identifier but not asset_type, or the value is empty/non-string.

Common situations: Incomplete vector store upload config; typo in 'asset_identifier' vs 'asset_id'; asset type set to a non-string value.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/650e19c843273e98. Report an issue: GitHub.