jstedfast/MailKit · error · FormatException
An annotation entry cannot be empty.
Error message
An annotation entry cannot be empty.
What it means
Validation inside AnnotationEntry.Parse: after the null check, an empty string is rejected with FormatException because an annotation entry must contain a mailbox path, entry name and value; there is nothing to parse from an empty string.
Solutions
- Skip empty strings before calling Parse (filter after splitting)
- Validate entry.Length > 0 and handle the empty case explicitly
- Fix the source so a real entry string is provided
Example fix
// before
foreach (var s in raw.Split (','))
entries.Add (AnnotationEntry.Parse (s));
// after
foreach (var s in raw.Split (',', StringSplitOptions.RemoveEmptyEntries))
entries.Add (AnnotationEntry.Parse (s)); Defensive patterns
Strategy: validation
Validate before calling
var tokens = raw.Split (',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
foreach (var t in tokens)
entries.Add (AnnotationEntry.Parse (t)); Type guard
bool CanParse (string? entry) => !string.IsNullOrEmpty (entry);
Try / catch
try {
var annotation = AnnotationEntry.Parse (entry);
} catch (FormatException) {
logger.LogWarning ("Skipped empty or invalid annotation entry");
} Prevention
- Use RemoveEmptyEntries when splitting entry lists
- Validate non-empty before Parse when data may be blank
- Distinguish 'absent' (null) from 'empty' ('') in your config schema
When it happens
Trigger: Calling AnnotationEntry.Parse("") or Parse of a string that trimmed to empty — e.g. a config value that is an empty string, or string.Split producing empty tokens fed to Parse.
Common situations: Empty environment/config values, splitting an entry list on separators that yields blank items, initializing strings to "" and never populating them.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Value cannot be null. (Parameter 'entry')
- An annotation entry must begin with a '/' character.
- Invalid annotation entry.
- Value cannot be null. (Parameter 'entry')
- Annotation entry paths must not end with '/'.
AI-assisted analysis of jstedfast/MailKit@9d3859a785 (2026-09-15).
Data as JSON: /api/errors/87ad7f735a99c208.
Report an issue: GitHub.
Appendix: source
Thrown at MailKit/AnnotationEntry.cs:430
/// </summary>
/// <remarks>
/// Parses an annotation entry.
/// </remarks>
/// <param name="entry">The annotation entry.</param>
/// <returns>The parsed annotation entry.</returns>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="entry"/> is <see langword="null" />.
/// </exception>
/// <exception cref="System.FormatException">
/// <paramref name="entry"/> does not conform to the annotation entry syntax.
/// </exception>
public static AnnotationEntry Parse (string entry)
{
if (entry == null)
throw new ArgumentNullException (nameof (entry));
if (entry.Length == 0)
throw new FormatException ("An annotation entry cannot be empty.");
if (entry[0] != '/' && entry[0] != '*' && entry[0] != '%')
throw new FormatException ("An annotation entry must begin with a '/' character.");
var scope = AnnotationScope.Both;
int startIndex = 0, endIndex;
string? partSpecifier = null;
var component = 0;
var pc = entry[0];
string path;
for (int i = 1; i < entry.Length; i++) {
char c = entry[i];
if (c >= '0' && c <= '9' && pc == '/') {
if (component > 0)
throw new FormatException ("Invalid annotation entry.");
View on GitHub (pinned to 9d3859a785)