CitationMixin creates empty citations from empty source chunks and short quotes
Environment
Instructor 1.18.0 from current main, Python 3.10.17, macOS arm64, Pydantic 2.14.0, regex 2026.9.29. Found during code inspection and reproduced locally; no provider request is involved.
Reproduction
from instructor.v2.dsl.citation import CitationMixin
print(CitationMixin.model_validate(
{"substring_quotes": ["cat"]},
context={"context": ["", "The cat sleeps."]},
).substring_quotes)
Actual: ['', 'cat']; expected: ['cat'].
With context={"context": ""} and substring_quotes=["abcd"], the output is [''] rather than []. An empty quote is also retained in a nonempty source.
Cause and proposed fix
The fuzzy regex permits deleting a short quote completely, and an empty quote matches a zero-width span. Skip span searching when either the quote or source is empty. This keeps nonempty fuzzy matching and no-validation-context behavior intact.
I plan to submit this focused fix with regression tests. I searched existing citation/fuzzy/empty-quote PRs and found no matching fix. Code inspection and reproduction were performed by OpenAI Codex.
On main the supplied empty-chunk example returns only the matching quote, and empty sources and empty quotes yield no citations. Shipped in https://github.com/567-labs/instructor/pull/2884.