{"record":{"id":"2210d1827ff128d0","repo":"jstedfast/MailKit","slug":"annotation-entry-paths-must-not-end-with-annotationentry","errorCode":null,"errorMessage":"Annotation entry paths must not end with '.'.","messagePattern":"Annotation entry paths must not end with '\\.'\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"MailKit/AnnotationEntry.cs","lineNumber":152,"sourceCode":"\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\n\t\t\t\tpc = c;\n\t\t\t}\n\n\t\t\tint endIndex = path.Length - 1;\n\n\t\t\tif (path[endIndex] == '/')\n\t\t\t\tthrow new ArgumentException (\"Annotation entry paths must not end with '/'.\", nameof (path));\n\n\t\t\tif (path[endIndex] == '.')\n\t\t\t\tthrow new ArgumentException (\"Annotation entry paths must not end with '.'.\", nameof (path));\n\t\t}\n\n\t\tstatic void ValidatePartSpecifier (string partSpecifier)\n\t\t{\n\t\t\tif (partSpecifier == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (partSpecifier));\n\n\t\t\tchar pc = '\\0';\n\n\t\t\tfor (int i = 0; i < partSpecifier.Length; i++) {\n\t\t\t\tchar c = partSpecifier[i];\n\n\t\t\t\tif (!((c >= '0' && c <= '9') || c == '.') || (c == '.' && (pc == '.' || pc == '\\0')))\n\t\t\t\t\tthrow new ArgumentException (\"Invalid part-specifier.\", nameof (partSpecifier));\n\n\t\t\t\tpc = c;\n\t\t\t}\n","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/AnnotationEntry.cs#L134-L170","documentation":"AnnotationEntry.ValidatePath also rejects entry-name paths that end with a '.' character. A trailing dot would create an ambiguous or malformed annotation entry when combined with the .priv/.shared scope suffix. Thrown as ArgumentException naming the path parameter.","triggerScenarios":"Calling an AnnotationEntry constructor/factory with a path like \"comment.\" or \"/vendor/cmu.\" — i.e. path[path.Length-1] == '.'.","commonSituations":"Trailing punctuation introduced by copy-paste, template strings, or splitting entry strings on '.' and reassembling them incorrectly; config files where the value retains a trailing period.","solutions":["Remove the trailing '.' from the path string before passing it","Trim trailing dots: path = path.TrimEnd('.')","Validate the annotation entry name syntax before constructing"],"exampleFix":"// before\nvar entry = new AnnotationEntry (\"comment.\", AnnotationScope.Private);\n// after\nvar entry = new AnnotationEntry (\"comment.TrimEnd ('.'), AnnotationScope.Private);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty (path))\n    throw new ArgumentException (\"Path is required.\");\nif (path.EndsWith (\".\"))\n    throw new ArgumentException ($\"Path '{path}' must not end with '.'.\");","typeGuard":"bool IsValidPath (string? path) =>\n    !string.IsNullOrEmpty (path) && !path.EndsWith (\"/\") && !path.EndsWith (\".\");","tryCatchPattern":"try {\n    var entry = new AnnotationEntry (path, scope);\n} catch (ArgumentException ex) when (ex.ParamName == \"path\") {\n    logger.LogError (ex, \"Invalid annotation path: {Path}\", path);\n}","preventionTips":["TrimEnd('.') values sourced from config or user input","Never reassemble entry strings by splitting on '.' without care","Add a shared ValidateAnnotationPath helper used before all construction"],"tags":["imap","annotation","argument-validation"],"backgroundTag":"invalid-argument-value","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"}