Repository navigation
fix(sdk/go): write U+2028 and U+2029 raw in the compose hash - #1479
Merged
Merged
Conversation
Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
force-pushed
the
fix/go-sdk-line-separator
branch
from
October 23, 2026 05:11
5270721 to
236edda
Compare
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.
Problem
#1024 turned off HTML escaping in
toDeterministicJSON, butencoding/jsonescapes U+2028 and U+2029 regardless ofSetEscapeHTML(false). Python (ensure_ascii=False), JS (JSON.stringify) and Rust write them raw, so any compose containing either character gets a Go-only digest. For{"runner":"docker-compose","docker_compose_file":"a b c \\u2028"}:bf62f89b764e0b5393d31efd5480bcfaeb9ffdc3609aa6de021ba551e9311adecc33d87b0ef663d8256fa948b10a7b66e98fbe63d10207110a558a215070e0ffbf62f89b764e0b5393d31efd5480bcfaeb9ffdc3609aa6de021ba551e9311adeFix
After encoding, rewrite
/escapes to the raw characters. A plain string replace would be wrong: the six charactersin the content encode as\\u2028, which contains. The rewrite walks escape pairs, so an escaped backslash is copied through untouched.Verification
TestLineSeparatorsAreNotEscapedpins the canonical bytes (both separators plus a literal); it fails onnextand passes here.json.dumps(sort_keys=True, separators=(",", ":"), ensure_ascii=False), NodeJSON.stringify, andGetComposeHash.go test ./...: the same 26 tests fail before and after, all needing/var/run/dstack.sock(no simulator running); everything else passes.