{"record":{"id":"1df39681939b9a06","repo":"microsoft/semantic-kernel","slug":"google-api-version-apiversion-is-not-supported","errorCode":null,"errorMessage":"Google API version {apiVersion} is not supported.","messagePattern":"Google API version (.+?) is not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.Google/Core/ClientBase.cs","lineNumber":115,"sourceCode":"        if (this._bearerTokenProvider is not null && await this._bearerTokenProvider().ConfigureAwait(false) is { } bearerKey)\n        {\n            httpRequestMessage.Headers.Authorization =\n                new AuthenticationHeaderValue(\"Bearer\", bearerKey);\n        }\n        else if (!string.IsNullOrWhiteSpace(this._apiKey))\n        {\n            httpRequestMessage.Headers.Add(\"x-goog-api-key\", this._apiKey);\n        }\n\n        return httpRequestMessage;\n    }\n\n    protected static string GetApiVersionSubLink(GoogleAIVersion apiVersion)\n        => apiVersion switch\n        {\n            GoogleAIVersion.V1 => \"v1\",\n            GoogleAIVersion.V1_Beta => \"v1beta\",\n            _ => throw new NotSupportedException($\"Google API version {apiVersion} is not supported.\")\n        };\n\n    protected static string GetApiVersionSubLink(VertexAIVersion apiVersion)\n        => apiVersion switch\n        {\n            VertexAIVersion.V1 => \"v1\",\n            VertexAIVersion.V1_Beta => \"v1beta1\",\n            _ => throw new NotSupportedException($\"Vertex API version {apiVersion} is not supported.\")\n        };\n\n    /// <summary>\n    /// Gets the Vertex AI endpoint base URI for the given location.\n    /// The global location uses <c>https://aiplatform.googleapis.com</c> while\n    /// regional locations use <c>https://{location}-aiplatform.googleapis.com</c>.\n    /// </summary>\n    protected static string GetVertexAIBaseUri(string location)\n        => string.Equals(location, \"global\", StringComparison.OrdinalIgnoreCase)\n            ? \"https://aiplatform.googleapis.com\"","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.Google/Core/ClientBase.cs#L97-L133","documentation":"Thrown by ClientBase.GetApiVersionSubLink(GoogleAIVersion) when the enum value is neither GoogleAIVersion.V1 nor GoogleAIVersion.V1_Beta. The switch maps these two to URL path segments ('v1', 'v1beta'). Any other enum value — which can only arise from an invalid cast or a future enum member not yet handled — triggers this NotSupportedException.","triggerScenarios":"Casting an arbitrary integer to GoogleAIVersion that does not correspond to V1 or V1_Beta. A future SDK version adds a new GoogleAIVersion enum member (e.g. V2) that this connector version does not handle. Using '(GoogleAIVersion)999' or similar invalid casts.","commonSituations":"Library version mismatch where a newer Google AI SDK introduces a new enum value not supported by the current Semantic Kernel connector. Reflective or dynamic code that casts integers to enums. Unit tests that construct invalid enum values.","solutions":["Use GoogleAIVersion.V1 or GoogleAIVersion.V1_Beta explicitly when configuring the connector.","If a new API version is needed, upgrade the Connectors.Google package to a release that supports it.","Avoid casting arbitrary integers to GoogleAIVersion; use the named enum values."],"exampleFix":"// before — invalid cast\nvar version = (GoogleAIVersion)someInt;\n\n// after — use named enum value\nvar version = GoogleAIVersion.V1;","handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(typeof(GoogleAIVersion), apiVersion) ||\n    (apiVersion != GoogleAIVersion.V1 && apiVersion != GoogleAIVersion.V1_Beta))\n{\n    throw new ArgumentOutOfRangeException(nameof(apiVersion),\n        $\"GoogleAIVersion must be V1 or V1_Beta. Got {apiVersion}.\");\n}","typeGuard":"static bool IsSupportedGoogleVersion(GoogleAIVersion v) =>\n    v == GoogleAIVersion.V1 || v == GoogleAIVersion.V1_Beta;","tryCatchPattern":"null","preventionTips":["Always use the named GoogleAIVersion enum values; never cast integers.","When upgrading the SDK, check for new enum members and verify connector support."],"tags":["google","versioning","enum","notsupported"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}