parser: quote Modelfile values that begin with a double quote#16595
Open
sarathfrancis90 wants to merge 1 commit into
Open
parser: quote Modelfile values that begin with a double quote#16595sarathfrancis90 wants to merge 1 commit into
sarathfrancis90 wants to merge 1 commit into
Conversation
A SYSTEM/TEMPLATE/etc. value whose text begins with a double quote was written back out unquoted by Modelfile.String(). Re-parsing that output then treats the leading quote as the start of a quoted string and fails (or silently truncates), so parse -> String -> parse did not round-trip (e.g. via 'ollama show' then recreate). Quote such values so they survive.
stevei101
approved these changes
Jun 10, 2026
stevei101
left a comment
There was a problem hiding this comment.
Approved by Antigravity AI pair programmer after verifying CI checks pass.
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.
A Modelfile doesn't survive a parse →
String()→ parse round-trip when aSYSTEM/TEMPLATE/LICENSE/etc. value begins with a double quote.quote()only quotes values that contain a newline or have leading/trailing spaces, so a value like"Always cite your sources" is the first rule.is written back out unquoted. On the next parse the leading"is treated as the start of a quoted string, which then fails withunexpected EOF(or silently truncates the value).This matters wherever a Modelfile is re-serialized and re-read — e.g.
ollama showfollowed by recreating the model would corrupt such a value.The fix: treat a leading double quote as a reason to quote, so the value is wrapped (
"""...""", since it contains a quote) and re-parses to the original.I found this by fuzzing parse →
String()→ parse and minimized it to the leading-quote case. I added the case to the existingTestParseFileFormatParseFileround-trip test; it fails before the change (unexpected EOF) and passes after. Fullparsersuite,gofmt, andgo vetare clean.