- char *term = talloc_asprintf (query, "%s%s", _find_prefix ("tag"), tag);
+ notmuch_status_t status;
+ char *term;
+
+ status = _notmuch_query_ensure_parsed (query);
+ /* The following is not ideal error handling, but to avoid
+ * breaking the ABI, we can live with it for now. In particular at
+ * least in the notmuch CLI, any syntax error in the query is
+ * caught in a later call to _notmuch_query_ensure_parsed with a
+ * better error path.
+ *
+ * TODO: add status return to this function.
+ */
+ if (status)
+ return;
+
+ term = talloc_asprintf (query, "%s%s", _find_prefix ("tag"), tag);
+ if (query->terms.count(term) != 0)
+ return; /* XXX report ignoring exclude? */
+