{"record":{"id":"01dac53c5400c824","repo":"microsoft/semantic-kernel","slug":"poolingmode","errorCode":null,"errorMessage":"PoolingMode","messagePattern":"PoolingMode","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.Onnx/BertOnnxOptions.cs","lineNumber":91,"sourceCode":"        init\n        {\n            Verify.NotNullOrWhiteSpace(value);\n            this._padToken = value;\n        }\n    }\n\n    /// <summary>Gets or sets the type of Unicode normalization to perform on input text. Defaults to <see cref=\"NormalizationForm.FormD\"/>.</summary>\n    public NormalizationForm UnicodeNormalization { get; init; } = NormalizationForm.FormD;\n\n    /// <summary>Gets or sets the pooling mode to use when generating the fixed-length embedding result. Defaults to \"mean\".</summary>\n    public EmbeddingPoolingMode PoolingMode\n    {\n        get => this._poolingMode;\n        init\n        {\n            if (value is not (EmbeddingPoolingMode.Max or EmbeddingPoolingMode.Mean or EmbeddingPoolingMode.MeanSquareRootTokensLength))\n            {\n                throw new ArgumentOutOfRangeException(nameof(this.PoolingMode));\n            }\n\n            this._poolingMode = value;\n        }\n    }\n\n    /// <summary>Gets or sets whether the resulting embedding vectors should be explicitly normalized. Defaults to false.</summary>\n    /// <remarks>Normalized embeddings may be compared more efficiently, such as by using a dot product rather than cosine similarity.</remarks>\n    public bool NormalizeEmbeddings { get; set; } = false;\n}\n","sourceCodeStart":73,"sourceCodeEnd":102,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.Onnx/BertOnnxOptions.cs#L73-L102","documentation":"Thrown as an ArgumentOutOfRangeException during BertOnnxOptions initialization when PoolingMode is set to a value other than Max, Mean, or MeanSquareRootTokensLength. These are the only pooling strategies the BERT ONNX embedding service supports. Using an undefined enum value or an unsupported one triggers the error.","triggerScenarios":"Setting PoolingMode to EmbeddingPoolingMode.None or any value outside the three supported modes; deserializing a config string that maps to an unsupported enum value.","commonSituations":"Configuration specifies a pooling mode string like 'none' or 'cls' that is not supported; enum cast from an integer that does not correspond to a valid supported mode; copy from a different model's config that uses a different pooling strategy.","solutions":["Use EmbeddingPoolingMode.Mean (default), .Max, or .MeanSquareRootTokensLength.","Validate the pooling mode string against supported values before assignment.","If using 'cls' pooling, note it is not supported by this connector; consider a different ONNX embedding service."],"exampleFix":"// before\nvar options = new BertOnnxOptions { PoolingMode = (EmbeddingPoolingMode)99 };\n\n// after\nvar options = new BertOnnxOptions { PoolingMode = EmbeddingPoolingMode.Mean };","handlingStrategy":"validation","validationCode":"var supported = new[]\n{\n    EmbeddingPoolingMode.Max,\n    EmbeddingPoolingMode.Mean,\n    EmbeddingPoolingMode.MeanSquareRootTokensLength\n};\nif (!supported.Contains(configuredPooling))\n    throw new InvalidOperationException(\"Unsupported pooling mode.\");","typeGuard":"static bool IsValidPoolingMode(EmbeddingPoolingMode mode) =>\n    mode is EmbeddingPoolingMode.Max or\n           EmbeddingPoolingMode.Mean or\n           EmbeddingPoolingMode.MeanSquareRootTokensLength;","tryCatchPattern":null,"preventionTips":["Check the connector docs for supported pooling modes.","Validate config strings against the supported set before assignment.","Default to Mean if unsure."],"tags":["onnx","bert","pooling-mode","configuration","argument-out-of-range"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}