{"record":{"id":"393309086cd9bc39","repo":"microsoft/semantic-kernel","slug":"dictionary","errorCode":null,"errorMessage":"dictionary","messagePattern":"dictionary","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.Google/Models/Gemini/GeminiMetadata.cs","lineNumber":137,"sourceCode":"    /// The thought signature for text responses with thinking enabled.\n    /// </summary>\n    /// <remarks>\n    /// When thinking is enabled, Gemini may return a signature on the last text part that should\n    /// be included in subsequent requests to maintain optimal reasoning quality. Unlike function\n    /// call signatures, text response signatures are recommended but not strictly validated.\n    /// </remarks>\n    public string? ThoughtSignature\n    {\n        get => this.GetValueFromDictionary(nameof(this.ThoughtSignature)) as string;\n        internal init => this.SetValueInDictionary(value, nameof(this.ThoughtSignature));\n    }\n\n    /// <summary>\n    /// Converts a dictionary to a <see cref=\"GeminiMetadata\"/> object.\n    /// </summary>\n    public static GeminiMetadata FromDictionary(IReadOnlyDictionary<string, object?> dictionary) => dictionary switch\n    {\n        null => throw new ArgumentNullException(nameof(dictionary)),\n        GeminiMetadata metadata => metadata,\n        IDictionary<string, object?> metadata => new GeminiMetadata(metadata),\n        _ => new GeminiMetadata(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":119,"sourceCodeEnd":149,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.Google/Models/Gemini/GeminiMetadata.cs#L119-L149","documentation":"Thrown by GeminiMetadata.FromDictionary when the dictionary argument is null. FromDictionary converts a raw response dictionary into a GeminiMetadata; passing null is a programming error. The message 'dictionary' is the parameter name from nameof(dictionary) on the ArgumentNullException.","triggerScenarios":"Calling GeminiMetadata.FromDictionary(null) directly, or a code path that supplies a null dictionary (e.g. a metadata accessor returning null from the API response being forwarded into FromDictionary).","commonSituations":"Forwarding a possibly-null metadata dictionary without a null check; deserialization helpers that yield null on empty responses; refactors that drop a prior non-null guarantee.","solutions":["Null-check before calling FromDictionary and skip or use an empty dictionary when null.","Ensure the upstream response always produces a non-null dictionary (the connector normally does this).","Pass new Dictionary<string,object?>() instead of null for absent metadata."],"exampleFix":"// before\nvar meta = GeminiMetadata.FromDictionary(raw);  // raw may be null\n\n// after\nvar meta = raw is null ? null : GeminiMetadata.FromDictionary(raw);","handlingStrategy":"validation","validationCode":"static GeminiMetadata? SafeFromDict(IReadOnlyDictionary<string,object?>? d)\n    => d is null ? null : GeminiMetadata.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":["gemini","metadata","null-argument"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}