{"record":{"id":"2c2ae61ec0dd01e2","repo":"jstedfast/MailKit","slug":"only-the-value-value-priv-and-value-shared-attributes-can-be","errorCode":null,"errorMessage":"Only the \"value\", \"value.priv\", and \"value.shared\" attributes can be searched.","messagePattern":"Only the \"value\", \"value\\.priv\", and \"value\\.shared\" attributes can be searched\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"MailKit/Search/AnnotationSearchQuery.cs","lineNumber":65,"sourceCode":"\t\t/// <param name=\"value\">The annotation attribute value.</param>\n\t\t/// <exception cref=\"System.ArgumentNullException\">\n\t\t/// <para><paramref name=\"entry\"/> is <see langword=\"null\" />.</para>\n\t\t/// <para>-or-</para>\n\t\t/// <para><paramref name=\"attribute\"/> is <see langword=\"null\" />.</para>\n\t\t/// </exception>\n\t\t/// <exception cref=\"System.ArgumentException\">\n\t\t/// <paramref name=\"attribute\"/> is not a valid attribute for searching.\n\t\t/// </exception>\n\t\tpublic AnnotationSearchQuery (AnnotationEntry entry, AnnotationAttribute attribute, string value) : base (SearchTerm.Annotation)\n\t\t{\n\t\t\tif (entry is null)\n\t\t\t\tthrow new ArgumentNullException (nameof (entry));\n\n\t\t\tif (attribute is null)\n\t\t\t\tthrow new ArgumentNullException (nameof (attribute));\n\n\t\t\tif (attribute.Name != \"value\")\n\t\t\t\tthrow new ArgumentException (\"Only the \\\"value\\\", \\\"value.priv\\\", and \\\"value.shared\\\" attributes can be searched.\", nameof (attribute));\n\n\t\t\tAttribute = attribute;\n\t\t\tEntry = entry;\n\t\t\tValue = value;\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Get the annotation entry.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// Gets the annotation entry.\n\t\t/// </remarks>\n\t\t/// <value>The annotation entry.</value>\n\t\tpublic AnnotationEntry Entry {\n\t\t\tget; private set;\n\t\t}\n\n\t\t/// <summary>","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Search/AnnotationSearchQuery.cs#L47-L83","documentation":"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.","triggerScenarios":"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.","commonSituations":"Typo in the attribute name string; confusing annotation attributes with metadata entries; copying attribute names from server CAPABILITY output that lists non-searchable attributes.","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."],"exampleFix":"// before\nvar attr = AnnotationAttribute.FromName(\"size\");\nvar query = new AnnotationSearchQuery(AnnotationEntry.All, attr, \"1024\");\n// after\nvar attr = AnnotationAttribute.FromName(\"value.shared\");\nvar query = new AnnotationSearchQuery(AnnotationEntry.All, attr, \"1024\");","handlingStrategy":"validation","validationCode":"if (attribute?.Name != \"value\") throw new InvalidOperationException(\"only value/value.priv/value.shared attributes are searchable\");","typeGuard":"bool IsSearchableAttribute(AnnotationAttribute a) => a != null && a.Name == \"value\";","tryCatchPattern":"try { var q = new AnnotationSearchQuery(entry, attribute, value); } catch (ArgumentException ex) { /* attribute not searchable; surface to caller */ }","preventionTips":["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"],"tags":["csharp","mailkit","imap","annotate-extension","search-query"],"backgroundTag":"invalid-enum-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"}