Repository navigation
common : handle missing gbnf regex anchors with .* fallback - #26915
RayanVakil wants to merge 1 commit into
Conversation
|
Hi @RayanVakil, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
|
This makes the GBNF grammar accept anything, rendering it useless. |
|
@aldehir Ah yeah, good call. I was mostly just trying to hotfix a regex compiler crash that was bricking my local pipeline, but you're completely right. Injecting .* totally defeats the strict token constraints of GBNF by letting the model hallucinate whatever it wants before or after the schema. I'll go ahead and close this out. Thanks for the quick review and catching the broader impact! |
Overview
This PR addresses a strict validation failure in
json-schema-to-grammar.cpp. When a JSON schema pattern lacks^or$anchors, the current regex compiler throws a hard error. This patch surgically modifies_visit_patternto gracefully fallback by prepending/appending.*to unanchored patterns. This ensures valid GBNF grammar generation without breaking existing anchored schema validations.Requirements