Repository navigation
Conversation
Jinja2ChatFormatter renders chat templates from model metadata using jinja2’s sandboxed environment. When a template calls range() with more than MAX_RANGE (100000) items, the sandbox raises OverflowError — which is not a TemplateError subclass. Since __call__ did not catch it, the exception escaped and crashed the caller (e.g. every POST /v1/chat/completions request for a model whose GGUF embeds such a template returned a raw traceback instead of a clean error). Fix: wrap the render(...) call and translate OverflowError into ValueError, matching the error contract already used by the raise_exception helper in the same method. The sandbox behavior itself is unchanged — only the error surface is normalized
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jinja2ChatFormatter renders chat templates from model metadata using jinja2’s sandboxed environment. When a template calls range() with more than MAX_RANGE (100000) items, the sandbox raises OverflowError — which is not a TemplateError subclass. Since call did not catch it, the exception escaped and crashed the caller (e.g. every POST /v1/chat/completions request for a model whose GGUF embeds such a template returned a raw traceback instead of a clean error).
Fix: wrap the render(...) call and translate OverflowError into ValueError, matching the error contract already used by the raise_exception helper in the same method. The sandbox behavior itself is unchanged — only the error surface is normalized