Skip to content

fix(sdk/go): write U+2028 and U+2029 raw in the compose hash - #1479

Merged
kvinwang merged 1 commit into
nextfrom
fix/go-sdk-line-separator
Oct 23, 2026
Merged

kvinwang merged 1 commit into
nextfrom
fix/go-sdk-line-separator

Conversation

@kvinwang

Copy link
Copy Markdown
Collaborator

Problem

#1024 turned off HTML escaping in toDeterministicJSON, but encoding/json escapes U+2028 and U+2029 regardless of SetEscapeHTML(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"}:

SDK sha256
Python / JS bf62f89b764e0b5393d31efd5480bcfaeb9ffdc3609aa6de021ba551e9311ade
Go before cc33d87b0ef663d8256fa948b10a7b66e98fbe63d10207110a558a215070e0ff
Go after bf62f89b764e0b5393d31efd5480bcfaeb9ffdc3609aa6de021ba551e9311ade

Fix

After encoding, rewrite 
/
 escapes to the raw characters. A plain string replace would be wrong: the six characters 
 in the content encode as \\u2028, which contains 
. The rewrite walks escape pairs, so an escaped backslash is copied through untouched.

Verification

  • New TestLineSeparatorsAreNotEscaped pins the canonical bytes (both separators plus a literal 
); it fails on next and passes here.
  • Hashes in the table computed with Python 3 json.dumps(sort_keys=True, separators=(",", ":"), ensure_ascii=False), Node JSON.stringify, and GetComposeHash.
  • go test ./...: the same 26 tests fail before and after, all needing /var/run/dstack.sock (no simulator running); everything else passes.

Signed-off-by: Kevin Wang <wy721@qq.com>
@kvinwang
kvinwang force-pushed the fix/go-sdk-line-separator branch from 5270721 to 236edda Compare October 23, 2026 05:11
@kvinwang
kvinwang merged commit 048c523 into next Oct 23, 2026
8 checks passed
@kvinwang
kvinwang deleted the fix/go-sdk-line-separator branch October 23, 2026 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant