{"record":{"id":"39fb57b1b59d54e9","repo":"microsoft/semantic-kernel","slug":"unsupported-service-type","errorCode":null,"errorMessage":"Unsupported service type","messagePattern":"Unsupported service type","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.Amazon/Bedrock/Core/Clients/BedrockTextEmbeddingGenerationClient.cs","lineNumber":45,"sourceCode":"    {\n        var serviceFactory = new BedrockServiceFactory();\n        this._modelId = modelId;\n        this._bedrockRuntime = bedrockRuntime;\n        this._ioVectorGenerationService = serviceFactory.CreateTextEmbeddingService(modelId);\n        this._logger = loggerFactory?.CreateLogger(this.GetType()) ?? NullLogger.Instance;\n    }\n\n    internal async Task<IList<ReadOnlyMemory<float>>> GenerateEmbeddingsAsync(\n        IList<string> texts,\n        CancellationToken cancellationToken = default)\n    {\n        Verify.NotNullOrEmpty(texts);\n\n        return this._ioVectorGenerationService switch\n        {\n            IBedrockCommonSplitTextEmbeddingGenerationService => await this.GenerateSingleEmbeddingsAsync(texts, cancellationToken).ConfigureAwait(false),\n            IBedrockCommonBatchTextEmbeddingGenerationService => await this.GenerateBatchEmbeddingsAsync(texts, cancellationToken).ConfigureAwait(false),\n            _ => throw new NotSupportedException(\"Unsupported service type\")\n        };\n    }\n\n    private async Task<IList<ReadOnlyMemory<float>>> GenerateSingleEmbeddingsAsync(\n        IList<string> texts,\n        CancellationToken cancellationToken = default\n    )\n    {\n        var embeddings = new List<ReadOnlyMemory<float>>();\n        foreach (var item in texts)\n        {\n            try\n            {\n                var embedding = await this.GetEmbeddingForSingleTextAsync(item, cancellationToken).ConfigureAwait(false);\n                embeddings.Add(embedding);\n            }\n            catch (Exception ex)\n            {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.Amazon/Bedrock/Core/Clients/BedrockTextEmbeddingGenerationClient.cs#L27-L63","documentation":"Thrown by BedrockTextEmbeddingGenerationClient.GenerateEmbeddingsAsync when the resolved _ioVectorGenerationService implements neither IBedrockCommonSplitTextEmbeddingGenerationService nor IBedrockCommonBatchTextEmbeddingGenerationService. The switch expression's default arm is unreachable with the shipped factory (which only returns Amazon/Cohere embedding services that implement one of those interfaces), so this is a safety net against an unexpected service type.","triggerScenarios":"Practically unreachable through public APIs: CreateTextEmbeddingService only returns AmazonEmbedGenerationService or CohereEmbedGenerationService, both of which implement one of the two interfaces. Could surface only if a custom/patched service is injected or a future embedding model is wired to a service class that implements IBedrockCommonTextEmbeddingGenerationService but neither split nor batch.","commonSituations":"Contributor added a new Bedrock embedding model+service but forgot to implement the split or batch marker interface. Reflection/diagnostic substitution of the service. Not something end users hit in released packages.","solutions":["Confirm you are using an unmodified Connectors.Amazon package; if patched, ensure the embedding service class implements IBedrockCommonSplitTextEmbeddingGenerationService or IBedrockCommonBatchTextEmbeddingGenerationService.","If contributing a new embedding provider, have the service implement one of those marker interfaces and map it in BedrockServiceFactory.CreateTextEmbeddingService.","Report a bug against the connector if it reproduces on an unmodified release."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Unreachable on released packages; only relevant when injecting a custom service.\nvar svc = factory.CreateTextEmbeddingService(modelId);\nif (svc is not IBedrockCommonSplitTextEmbeddingGenerationService\n && svc is not IBedrockCommonBatchTextEmbeddingGenerationService)\n    throw new InvalidOperationException(\"Embedding service does not implement split or batch interface.\");","typeGuard":"bool SupportsEmbeddingGeneration(IBedrockCommonTextEmbeddingGenerationService svc)\n    => svc is IBedrockCommonSplitTextEmbeddingGenerationService\n    || svc is IBedrockCommonBatchTextEmbeddingGenerationService;","tryCatchPattern":"try { await client.GenerateEmbeddingsAsync(texts, ct); }\ncatch (NotSupportedException ex) when (ex.Message == \"Unsupported service type\")\n{ /* report a connector bug / ensure no patched service is in use */ throw; }","preventionTips":["If you maintain a fork, ensure new embedding services implement the split or batch marker interface.","File an issue if this reproduces on an unmodified Connectors.Amazon release."],"tags":["bedrock","embeddings","internal","csharp"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}