jstedfast/MailKit · error · ArgumentException
Only the "value", "value.priv", and "value.shared"…
Error message
Only the "value", "value.priv", and "value.shared" attributes can be searched.
What it means
AnnotationSearchQuery rejects any AnnotationAttribute whose Name is not exactly "value" — the family "value", "value.priv", and "value.shared" all share the base name "value". Attributes with any other name (e.g. "size", "mbox") cannot be searched for a text value, so the library throws ArgumentException immediately.
Solutions
- Use AnnotationAttribute.FromName("value"), FromName("value.priv"), or FromName("value.shared").
- Validate attribute.Name == "value" (or one of the three allowed names) before constructing the query.
- If you need to search a different annotation property, that operation is not supported — restructure the query around the value attributes.
Example fix
// before
var attr = AnnotationAttribute.FromName("size");
var query = new AnnotationSearchQuery(AnnotationEntry.All, attr, "1024");
// after
var attr = AnnotationAttribute.FromName("value.shared");
var query = new AnnotationSearchQuery(AnnotationEntry.All, attr, "1024"); Defensive patterns
Strategy: validation
Validate before calling
if (attribute?.Name != "value") throw new InvalidOperationException("only value/value.priv/value.shared attributes are searchable"); Type guard
bool IsSearchableAttribute(AnnotationAttribute a) => a != null && a.Name == "value";
Try / catch
try { var q = new AnnotationSearchQuery(entry, attribute, value); } catch (ArgumentException ex) { /* attribute not searchable; surface to caller */ } Prevention
- Hardcode the three allowed attribute names in a whitelist
- Never pass attributes parsed from arbitrary server output
- Add a unit test asserting FromName calls use allowed names
When it happens
Trigger: Calling new AnnotationSearchQuery(entry, AnnotationAttribute.FromName("size"), text) or constructing an AnnotationAttribute with a custom/misspelled name that isn't one of the searchable value attributes.
Common situations: Typo in the attribute name string; confusing annotation attributes with metadata entries; copying attribute names from server CAPABILITY output that lists non-searchable attributes.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- The filter name cannot be empty.
- Metadata tag does not reference a valid filter.
- The uid is invalid.
- Value cannot be null. (Parameter 'name')
- Value cannot be null. (Parameter 'rights')
AI-assisted analysis of jstedfast/MailKit@9d3859a785 (2026-09-15).
Data as JSON: /api/errors/2c2ae61ec0dd01e2.
Report an issue: GitHub.
Appendix: source
Thrown at MailKit/Search/AnnotationSearchQuery.cs:65
/// <param name="value">The annotation attribute value.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="entry"/> is <see langword="null" />.</para>
/// <para>-or-</para>
/// <para><paramref name="attribute"/> is <see langword="null" />.</para>
/// </exception>
/// <exception cref="System.ArgumentException">
/// <paramref name="attribute"/> is not a valid attribute for searching.
/// </exception>
public AnnotationSearchQuery (AnnotationEntry entry, AnnotationAttribute attribute, string value) : base (SearchTerm.Annotation)
{
if (entry is null)
throw new ArgumentNullException (nameof (entry));
if (attribute is null)
throw new ArgumentNullException (nameof (attribute));
if (attribute.Name != "value")
throw new ArgumentException ("Only the \"value\", \"value.priv\", and \"value.shared\" attributes can be searched.", nameof (attribute));
Attribute = attribute;
Entry = entry;
Value = value;
}
/// <summary>
/// Get the annotation entry.
/// </summary>
/// <remarks>
/// Gets the annotation entry.
/// </remarks>
/// <value>The annotation entry.</value>
public AnnotationEntry Entry {
get; private set;
}
/// <summary>View on GitHub (pinned to 9d3859a785)