{"record":{"id":"c2ab716e56d6c787","repo":"jstedfast/MailKit","slug":"value-cannot-be-null-parameter-path","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'path')","messagePattern":"Value cannot be null\\. \\(Parameter 'path'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"MailKit/AnnotationEntry.cs","lineNumber":115,"sourceCode":"\t\t/// An annotation entry for a private alternate subject on a message.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// Used to get or set a private alternate subject on a message.\n\t\t/// </remarks>\n\t\tpublic static readonly AnnotationEntry PrivateAltSubject = new AnnotationEntry (\"/altsubject\", AnnotationScope.Private);\n\n\t\t/// <summary>\n\t\t/// An annotation entry for a shared alternate subject on a message.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// Used to get or set a shared alternate subject on a message.\n\t\t/// </remarks>\n\t\tpublic static readonly AnnotationEntry SharedAltSubject = new AnnotationEntry (\"/altsubject\", AnnotationScope.Shared);\n\n\t\tstatic void ValidatePath (string path)\n\t\t{\n\t\t\tif (path == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (path));\n\n\t\t\tif (path.Length == 0)\n\t\t\t\tthrow new ArgumentException (\"Annotation entry paths cannot be empty.\", nameof (path));\n\n\t\t\tif (path[0] != '/' && path[0] != '*' && path[0] != '%')\n\t\t\t\tthrow new ArgumentException (\"Annotation entry paths must begin with '/'.\", nameof (path));\n\n\t\t\tif (path.Length > 1 && path[1] >= '0' && path[1] <= '9')\n\t\t\t\tthrow new ArgumentException (\"Annotation entry paths must not include a part-specifier.\", nameof (path));\n\n\t\t\tif (path == \"*\" || path == \"%\")\n\t\t\t\treturn;\n\n\t\t\tchar pc = path[0];\n\n\t\t\tfor (int i = 1; i < path.Length; i++) {\n\t\t\t\tchar c = path[i];\n","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/AnnotationEntry.cs#L97-L133","documentation":"AnnotationEntry.ValidatePath throws ArgumentNullException when the annotation entry path is null. Every IMAP annotation entry must be identified by a path such as \"/comment\", so a null path is rejected by the AnnotationEntry constructors.","triggerScenarios":"Calling a AnnotationEntry constructor or static field-style factory with `new AnnotationEntry(null, scope)` or with a null value returned from a lookup.","commonSituations":"Reading entry names from config or parsed IMAP responses where the value is missing; nullable variables passed directly into the constructor.","solutions":["Check the path for null before calling any AnnotationEntry constructor.","Fix the data source so it always provides an entry path.","Coalesce to a valid default path only if semantically appropriate."],"exampleFix":"// before\nvar entry = new AnnotationEntry(config[\"Entry\"], AnnotationScope.Shared);\n// after\nvar path = config[\"Entry\"];\nif (path == null)\n    throw new InvalidOperationException(\"Annotation entry path not configured\");\nvar entry = new AnnotationEntry(path, AnnotationScope.Shared);","handlingStrategy":"validation","validationCode":"if (path == null)\n    throw new InvalidOperationException(\"Annotation entry path is required\");\nvar entry = new AnnotationEntry(path, AnnotationScope.Shared);","typeGuard":"bool IsValidEntryPath(string p) => p != null && p.Length > 0 && (p[0] == '/' || p == \"*\" || p == \"%\");","tryCatchPattern":"try\n{\n    var entry = new AnnotationEntry(path, AnnotationScope.Shared);\n}\ncatch (ArgumentNullException)\n{\n    // path was null — supply a valid path or abort\n}","preventionTips":["Resolve nullable path variables before constructing entries.","Load and validate annotation paths once at startup.","Use named constants for well-known entry paths (e.g. \"/comment\")."],"tags":["mailkit","imap","annotations","argument-null"],"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"}