{"record":{"id":"fa4246569ebee23f","repo":"jstedfast/MailKit","slug":"annotation-entry-paths-must-not-include-a-part-specifier","errorCode":null,"errorMessage":"Annotation entry paths must not include a part-specifier.","messagePattern":"Annotation entry paths must not include a part-specifier\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"MailKit/AnnotationEntry.cs","lineNumber":124,"sourceCode":"\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\n\t\t\t\tif ((pc == '/' || pc == '.') && (c == '/' || c == '.'))\n\t\t\t\t\tthrow new ArgumentException (\"Invalid annotation entry path.\", nameof (path));\n","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/AnnotationEntry.cs#L106-L142","documentation":"AnnotationEntry.ValidatePath throws ArgumentException when the second character of the path is a digit, which in RFC 5257 denotes a MIME part specifier (e.g. \"/1/comment\"). Entry paths passed to AnnotationEntry must not embed a part specifier.","triggerScenarios":"Calling `new AnnotationEntry(\"/1/comment\", scope)` or building paths like \"/2.alt/text\" that include a numeric part selector after the leading '/'.","commonSituations":"Constructing annotations for specific MIME parts of a message (bodypart annotations) by hand-embedding the part number instead of using the library's API that accepts part specifiers; copying paths from raw IMAP transcripts.","solutions":["Remove the part-specifier segment from the path (e.g. \"/1/comment\" -> \"/comment\").","Use the appropriate MailKit API overload that handles part-specific annotations rather than encoding the part number in the path.","If part annotation is required, verify the library version supports it and use the documented entry format."],"exampleFix":"// before\nvar entry = new AnnotationEntry(\"/1/comment\", AnnotationScope.Shared);\n// after\nvar entry = new AnnotationEntry(\"/comment\", AnnotationScope.Shared);","handlingStrategy":"validation","validationCode":"if (path != null && path.Length > 1 && path[1] >= '0' && path[1] <= '9')\n    throw new FormatException(\"Entry path must not embed a MIME part specifier\");\nvar entry = new AnnotationEntry(path, AnnotationScope.Shared);","typeGuard":"bool HasPartSpecifier(string p) => p != null && p.Length > 1 && char.IsDigit(p[1]);","tryCatchPattern":"try\n{\n    var entry = new AnnotationEntry(path, AnnotationScope.Shared);\n}\ncatch (ArgumentException ex) when (ex.ParamName == \"path\")\n{\n    // strip the part-specifier segment or use a part-aware API\n}","preventionTips":["Never hand-embed part numbers like \"/1/\" into entry paths.","Check the library API for part-level annotation support instead of encoding parts in paths.","Document that AnnotationEntry paths are entry-level only."],"tags":["mailkit","imap","annotations","mime","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"}