{"record":{"id":"da937a9ccdf34e08","repo":"jstedfast/MailKit","slug":"value-cannot-be-null-parameter-entry-annotationentry","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'entry')","messagePattern":"Value cannot be null\\. \\(Parameter 'entry'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"MailKit/AnnotationEntry.cs","lineNumber":427,"sourceCode":"\n\t\t/// <summary>\n\t\t/// Parse an annotation entry.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// Parses an annotation entry.\n\t\t/// </remarks>\n\t\t/// <param name=\"entry\">The annotation entry.</param>\n\t\t/// <returns>The parsed annotation entry.</returns>\n\t\t/// <exception cref=\"System.ArgumentNullException\">\n\t\t/// <paramref name=\"entry\"/> is <see langword=\"null\" />.\n\t\t/// </exception>\n\t\t/// <exception cref=\"System.FormatException\">\n\t\t/// <paramref name=\"entry\"/> does not conform to the annotation entry syntax.\n\t\t/// </exception>\n\t\tpublic static AnnotationEntry Parse (string entry)\n\t\t{\n\t\t\tif (entry == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (entry));\n\n\t\t\tif (entry.Length == 0)\n\t\t\t\tthrow new FormatException (\"An annotation entry cannot be empty.\");\n\n\t\t\tif (entry[0] != '/' && entry[0] != '*' && entry[0] != '%')\n\t\t\t\tthrow new FormatException (\"An annotation entry must begin with a '/' character.\");\n\n\t\t\tvar scope = AnnotationScope.Both;\n\t\t\tint startIndex = 0, endIndex;\n\t\t\tstring? partSpecifier = null;\n\t\t\tvar component = 0;\n\t\t\tvar pc = entry[0];\n\t\t\tstring path;\n\n\t\t\tfor (int i = 1; i < entry.Length; i++) {\n\t\t\t\tchar c = entry[i];\n\n\t\t\t\tif (c >= '0' && c <= '9' && pc == '/') {","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/AnnotationEntry.cs#L409-L445","documentation":"Validation inside the static AnnotationEntry.Parse method: the 'entry' string to parse was null. Parsing requires the annotation entry string supplied by the caller (typically obtained from an IMAP ANNOTATE response), so a null string is rejected before parsing begins.","triggerScenarios":"Calling AnnotationEntry.Parse(null) or AnnotationEntry.Create(null), usually when the entry string came from an unpopulated variable, a missing dictionary value, or a null server response field.","commonSituations":"Reading annotation entries from config or a server response where the key was absent; deserializing data that omitted the entry field.","solutions":["Null-check the entry string before calling Parse","Default to an empty-string handling path (Parse gives a clearer FormatException for empty input) if that suits the flow","Fix the data source so the entry value is populated"],"exampleFix":"// before\nvar annotation = AnnotationEntry.Parse (response.Value);\n// after\nif (response.Value != null)\n    var annotation = AnnotationEntry.Parse (response.Value);","handlingStrategy":"type-guard","validationCode":"if (string.IsNullOrEmpty (entry))\n    return null; // or skip / report","typeGuard":"bool CanParse (string? entry) => !string.IsNullOrEmpty (entry);","tryCatchPattern":"try {\n    var annotation = AnnotationEntry.Parse (entry);\n} catch (ArgumentNullException) {\n    logger.LogWarning (\"Skipped annotation entry: null value\");\n}","preventionTips":["Null-check entry strings from config, responses, or dictionaries","Use ArgumentNullException.ThrowIfNull at your own API boundaries to fail early","Treat missing annotation data as optional, not mandatory"],"tags":["imap","annotation","null-argument","parsing"],"backgroundTag":"null-argument","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}