{"record":{"id":"4060a264d99c5ce9","repo":"jstedfast/MailKit","slug":"annotation-entry-paths-must-begin-with","errorCode":null,"errorMessage":"Annotation entry paths must begin with '/'.","messagePattern":"Annotation entry paths must begin with '/'\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"MailKit/AnnotationEntry.cs","lineNumber":121,"sourceCode":"\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\n\t\t\t\tif (c > 127)\n\t\t\t\t\tthrow new ArgumentException ($\"Invalid character in annotation entry path: '{c}'.\", nameof (path));\n\n\t\t\t\tif (c >= '0' && c <= '9' && pc == '/')\n\t\t\t\t\tthrow new ArgumentException (\"Invalid annotation entry path.\", nameof (path));\n","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/AnnotationEntry.cs#L103-L139","documentation":"AnnotationEntry.ValidatePath throws ArgumentException when the path does not begin with '/', '*', or '%'. RFC 5257 annotation entries are slash-rooted hierarchies (e.g. \"/comment\"), and only the special standalone wildcards '*' and '%' may omit the leading slash.","triggerScenarios":"Calling `new AnnotationEntry(\"comment\", ...)` or `new AnnotationEntry(\"/comment\".TrimStart('/'), ...)` — any path whose first char is not '/' or a wildcard.","commonSituations":"Passing a bare attribute-like name without the leading slash; stripping the leading '/' accidentally via trimming or normalization code; confusing attribute specifiers (unrooted, e.g. \"value.privacy\") with entry paths (rooted).","solutions":["Prefix the path with '/' if it is a rooted entry path missing the slash (e.g. \"comment\" -> \"/comment\").","Verify you are not passing an attribute specifier (like \"value.privacy\") where an entry path is expected.","Keep the standalone wildcards \"*\" or \"%\" if wildcard selection is intended."],"exampleFix":"// before\nvar entry = new AnnotationEntry(\"comment\", AnnotationScope.Shared);\n// after\nvar entry = new AnnotationEntry(\"/comment\", AnnotationScope.Shared);","handlingStrategy":"validation","validationCode":"if (path != null && path.Length > 0 && path[0] != '/' && path != \"*\" && path != \"%\")\n    path = \"/\" + path; // normalize to a rooted entry path\nvar entry = new AnnotationEntry(path, AnnotationScope.Shared);","typeGuard":"bool IsValidEntryPath(string p) => !string.IsNullOrEmpty(p) && (p[0] == '/' || p == \"*\" || p == \"%\");","tryCatchPattern":"try\n{\n    var entry = new AnnotationEntry(path, AnnotationScope.Shared);\n}\ncatch (ArgumentException ex) when (ex.ParamName == \"path\")\n{\n    // normalize: ensure leading '/' then retry or report\n}","preventionTips":["Normalize user-supplied paths to rooted form before construction.","Distinguish entry paths (rooted, e.g. \"/comment\") from attribute specifiers (e.g. \"value.privacy\").","Preserve standalone wildcards \"*\"/\"%\" when wildcard selection is intended."],"tags":["mailkit","imap","annotations","path-format"],"backgroundTag":"invalid-argument-format","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"}