jstedfast/MailKit · error · FormatException

Incomplete part-specifier in annotation entry.

Error message

Incomplete part-specifier in annotation entry.

What it means

After the part-specifier digits, the entry must continue (a '/', attribute name, and scope suffix must follow). AnnotationEntry.Parse throws FormatException when the entry ends right after the part-specifier, e.g. "/1" with nothing after the digits.

Solutions

  1. Append the full path: part-specifier, '/', attribute name (e.g. 'text' or 'size'), and a '.priv' or '.shared' suffix
  2. Use a complete entry like "/1.2/text.priv" instead of just "/1.2"
  3. Check the entry string length and content before calling Parse

Example fix

// before
var entry = AnnotationEntry.Parse ("/1.2");
// after
var entry = AnnotationEntry.Parse ("/1.2/text.priv");
Defensive patterns

Strategy: validation

Validate before calling

if (entry != null && entry.StartsWith ("/") && entry.EndsWith (".priv", StringComparison.Ordinal) || entry.EndsWith (".shared", StringComparison.Ordinal)) { /* ok */ }

Type guard

bool IsCompleteEntry (string entry) =>
    entry != null && entry.EndsWith (".priv", StringComparison.Ordinal) || entry.EndsWith (".shared", StringComparison.Ordinal);

Try / catch

try { var entry = AnnotationEntry.Parse (input); }
catch (FormatException ex) { log.Warn ($"Incomplete annotation entry '{input}': {ex.Message}"); }

Prevention

When it happens

Trigger: Calling AnnotationEntry.Parse or Create with a truncated entry such as "/1" or "/1.2" lacking the attribute component and scope suffix.

Common situations: Strings truncated by slicing/substring logic, entries built by concatenation where the attribute part was omitted, copy/paste that cut the entry short.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of jstedfast/MailKit@9d3859a785 (2026-09-15). Data as JSON: /api/errors/67d38343d9c9c9de. Report an issue: GitHub.

Appendix: source

Thrown at MailKit/AnnotationEntry.cs:474

						if (c == '/') {
							if (pc == '.')
								throw new FormatException ("Invalid part-specifier in annotation entry.");

							break;
						}

						if (!(c >= '0' && c <= '9') && c != '.')
							throw new FormatException ($"Invalid character in part-specifier: '{c}'.");

						if (c == '.' && pc == '.')
							throw new FormatException ("Invalid part-specifier in annotation entry.");

						endIndex++;
						pc = c;
					}

					if (endIndex >= entry.Length)
						throw new FormatException ("Incomplete part-specifier in annotation entry.");

					partSpecifier = entry.Substring (startIndex, endIndex - startIndex);
					i = startIndex = endIndex;
					component++;
				} else if (c == '/' || c == '.') {
					if (pc == '/' || pc == '.')
						throw new FormatException ("Invalid annotation entry path.");

					if (c == '/')
						component++;
				} else if (c > 127) {
					throw new FormatException ($"Invalid character in annotation entry path: '{c}'.");
				}

				pc = c;
			}

			if (pc == '/' || pc == '.')

View on GitHub (pinned to 9d3859a785)