jstedfast/MailKit · error · ArgumentException
Annotation entry paths must not end with '.'.
Error message
Annotation entry paths must not end with '.'.
What it means
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.
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
Example fix
// before
var entry = new AnnotationEntry ("comment.", AnnotationScope.Private);
// after
var entry = new AnnotationEntry ("comment.TrimEnd ('.'), AnnotationScope.Private); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty (path))
throw new ArgumentException ("Path is required.");
if (path.EndsWith ("."))
throw new ArgumentException ($"Path '{path}' must not end with '.'."); Type guard
bool IsValidPath (string? path) =>
!string.IsNullOrEmpty (path) && !path.EndsWith ("/") && !path.EndsWith ("."); Try / catch
try {
var entry = new AnnotationEntry (path, scope);
} catch (ArgumentException ex) when (ex.ParamName == "path") {
logger.LogError (ex, "Invalid annotation path: {Path}", path);
} Prevention
- 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
When it happens
Trigger: Calling an AnnotationEntry constructor/factory with a path like "comment." or "/vendor/cmu." — i.e. path[path.Length-1] == '.'.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Annotation entry paths must not end with '/'.
- Invalid part-specifier.
- Value cannot be null. (Parameter 'entry')
- Value cannot be null. (Parameter 'partSpecifier')
- Value cannot be null. (Parameter 'part')
AI-assisted analysis of jstedfast/MailKit@9d3859a785 (2026-09-15).
Data as JSON: /api/errors/2210d1827ff128d0.
Report an issue: GitHub.
Appendix: source
Thrown at MailKit/AnnotationEntry.cs:152
if (c > 127)
throw new ArgumentException ($"Invalid character in annotation entry path: '{c}'.", nameof (path));
if (c >= '0' && c <= '9' && pc == '/')
throw new ArgumentException ("Invalid annotation entry path.", nameof (path));
if ((pc == '/' || pc == '.') && (c == '/' || c == '.'))
throw new ArgumentException ("Invalid annotation entry path.", nameof (path));
pc = c;
}
int endIndex = path.Length - 1;
if (path[endIndex] == '/')
throw new ArgumentException ("Annotation entry paths must not end with '/'.", nameof (path));
if (path[endIndex] == '.')
throw new ArgumentException ("Annotation entry paths must not end with '.'.", nameof (path));
}
static void ValidatePartSpecifier (string partSpecifier)
{
if (partSpecifier == null)
throw new ArgumentNullException (nameof (partSpecifier));
char pc = '\0';
for (int i = 0; i < partSpecifier.Length; i++) {
char c = partSpecifier[i];
if (!((c >= '0' && c <= '9') || c == '.') || (c == '.' && (pc == '.' || pc == '\0')))
throw new ArgumentException ("Invalid part-specifier.", nameof (partSpecifier));
pc = c;
}
View on GitHub (pinned to 9d3859a785)