{"record":{"id":"ae589ff66d6a56da","repo":"microsoft/semantic-kernel","slug":"dictionary-ae589f","errorCode":null,"errorMessage":"dictionary","messagePattern":"dictionary","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.HuggingFace/Models/HuggingFaceTextGenerationStreamMetadata.cs","lineNumber":99,"sourceCode":"        get => this.GetValueFromDictionary(nameof(this.GeneratedTokens)) as int?;\n        internal init => this.SetValueInDictionary(value, nameof(this.GeneratedTokens));\n    }\n\n    /// <summary>\n    /// Finish reason.\n    /// </summary>\n    public string? FinishReason\n    {\n        get => this.GetValueFromDictionary(nameof(this.FinishReason)) as string;\n        internal init => this.SetValueInDictionary(value, nameof(this.FinishReason));\n    }\n\n    /// <summary>\n    /// Converts a dictionary to a <see cref=\"HuggingFaceChatCompletionMetadata\"/> object.\n    /// </summary>\n    public static HuggingFaceTextGenerationStreamMetadata FromDictionary(IReadOnlyDictionary<string, object?> dictionary) => dictionary switch\n    {\n        null => throw new ArgumentNullException(nameof(dictionary)),\n        HuggingFaceTextGenerationStreamMetadata metadata => metadata,\n        IDictionary<string, object?> metadata => new HuggingFaceTextGenerationStreamMetadata(metadata),\n        _ => new HuggingFaceTextGenerationStreamMetadata(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":81,"sourceCodeEnd":111,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.HuggingFace/Models/HuggingFaceTextGenerationStreamMetadata.cs#L81-L111","documentation":"Thrown by HuggingFaceTextGenerationStreamMetadata.FromDictionary when the dictionary argument is null. Same pattern as the sibling FromDictionary methods for streaming text-generation metadata; null is a caller error. Message 'dictionary' is the parameter name.","triggerScenarios":"Calling HuggingFaceTextGenerationStreamMetadata.FromDictionary(null) or forwarding a null dictionary from an upstream streamed response.","commonSituations":"Custom streaming pipelines forwarding possibly-null per-chunk metadata; refactors removing non-null guarantees.","solutions":["Null-check before calling FromDictionary.","Use an empty dictionary for absent stream metadata.","Guarantee the upstream stream parser produces non-null dictionaries."],"exampleFix":"// before\nvar meta = HuggingFaceTextGenerationStreamMetadata.FromDictionary(raw);  // raw may be null\n\n// after\nvar meta = raw is null ? null : HuggingFaceTextGenerationStreamMetadata.FromDictionary(raw);","handlingStrategy":"validation","validationCode":"static HuggingFaceTextGenerationStreamMetadata? SafeMeta(IReadOnlyDictionary<string,object?>? d)\n    => d is null ? null : HuggingFaceTextGenerationStreamMetadata.FromDictionary(d);","typeGuard":"static bool IsNonNullDict(IReadOnlyDictionary<string,object?>? d) => d is not null;","tryCatchPattern":null,"preventionTips":["Null-check before calling FromDictionary.","Use an empty dictionary for absent stream metadata.","Ensure the stream parser yields non-null dictionaries."],"tags":["huggingface","metadata","streaming","null-argument"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}