{"record":{"id":"3ae52602a233a0e5","repo":"microsoft/semantic-kernel","slug":"dictionary-3ae526","errorCode":null,"errorMessage":"dictionary","messagePattern":"dictionary","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.HuggingFace/Models/HuggingFaceChatCompletionMetadata.cs","lineNumber":125,"sourceCode":"        get => (this.GetValueFromDictionary(nameof(this.UsageCompletionTokens)) as int?);\n        internal init => this.SetValueInDictionary(value, nameof(this.UsageCompletionTokens));\n    }\n\n    /// <summary>\n    /// The log probabilities of the completion.\n    /// </summary>\n    public object? LogProbs\n    {\n        get => this.GetValueFromDictionary(nameof(this.LogProbs));\n        internal init => this.SetValueInDictionary(value, nameof(this.LogProbs));\n    }\n\n    /// <summary>\n    /// Converts a dictionary to a <see cref=\"HuggingFaceChatCompletionMetadata\"/> object.\n    /// </summary>\n    public static HuggingFaceChatCompletionMetadata FromDictionary(IReadOnlyDictionary<string, object?> dictionary) => dictionary switch\n    {\n        null => throw new ArgumentNullException(nameof(dictionary)),\n        HuggingFaceChatCompletionMetadata metadata => metadata,\n        IDictionary<string, object?> metadata => new HuggingFaceChatCompletionMetadata(metadata),\n        _ => new HuggingFaceChatCompletionMetadata(dictionary.ToDictionary(pair => pair.Key, pair => pair.Value))\n    };\n\n    private void SetValueInDictionary(object? value, string propertyName)\n        => this.Dictionary[propertyName] = value;\n\n    private object? GetValueFromDictionary(string propertyName)\n        => this.Dictionary.TryGetValue(propertyName, out var value) ? value : null;\n}\n","sourceCodeStart":107,"sourceCodeEnd":137,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.HuggingFace/Models/HuggingFaceChatCompletionMetadata.cs#L107-L137","documentation":"Thrown by HuggingFaceChatCompletionMetadata.FromDictionary when the dictionary argument is null. The method converts a raw response dictionary into a typed metadata object; null is a caller error. The message 'dictionary' is the nameof(dictionary) parameter name.","triggerScenarios":"Calling HuggingFaceChatCompletionMetadata.FromDictionary(null) directly, or passing a possibly-null dictionary produced upstream.","commonSituations":"Forwarding metadata from a response whose dictionary accessor returned null; refactors that removed a non-null guarantee; custom metadata adapters.","solutions":["Null-check before calling FromDictionary.","Pass an empty dictionary for absent metadata instead of null.","Ensure the upstream deserialization always yields a non-null dictionary."],"exampleFix":"// before\nvar meta = HuggingFaceChatCompletionMetadata.FromDictionary(raw);  // raw may be null\n\n// after\nvar meta = raw is null ? null : HuggingFaceChatCompletionMetadata.FromDictionary(raw);","handlingStrategy":"validation","validationCode":"static HuggingFaceChatCompletionMetadata? SafeMeta(IReadOnlyDictionary<string,object?>? d)\n    => d is null ? null : HuggingFaceChatCompletionMetadata.FromDictionary(d);","typeGuard":"static bool IsNonNullDict(IReadOnlyDictionary<string,object?>? d) => d is not null;","tryCatchPattern":null,"preventionTips":["Null-check before calling FromDictionary.","Pass an empty dictionary for absent metadata.","Guarantee upstream sources yield non-null dictionaries."],"tags":["huggingface","metadata","null-argument"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}