fix(session): session export checksum stored with sha256 prefix per spec #1450 (#1481)
CI / build (push) Successful in 15s
CI / lint (push) Failing after 21s
CI / helm (push) Successful in 32s
CI / typecheck (push) Failing after 46s
CI / coverage (push) Has been skipped
CI / benchmark-regression (push) Has been skipped
CI / security (push) Failing after 51s
CI / unit_tests (push) Has been cancelled
CI / e2e_tests (push) Has been cancelled
CI / integration_tests (push) Has been cancelled
CI / benchmark-publish (push) Has been cancelled
CI / quality (push) Has been cancelled
CI / docker (push) Has been cancelled
CI / status-check (push) Has been cancelled

Co-authored-by: Jeffrey Phillips Freeman <the@jeffreyfreeman.me>
Co-committed-by: Jeffrey Phillips Freeman <the@jeffreyfreeman.me>
This commit was merged in pull request #1481.
This commit is contained in:
2026-04-02 19:29:50 +00:00
committed by Forgejo
parent 19d4771aa2
commit b96154d612
2 changed files with 6 additions and 6 deletions
@@ -230,7 +230,7 @@ def step_import_invalid_messages(context):
The messages list contains an entry missing the required "role" key,
which will cause a KeyError during parsing and trigger lines 310-311.
"""
data_without_checksum = {
data_without_checksum = "sha256:" + {
"schema_version": EXPORT_SCHEMA_VERSION,
"session_id": "01JTESTIMPORT000000000000000",
"actor_name": None,
@@ -256,9 +256,9 @@ def step_import_invalid_messages(context):
# Compute a valid checksum so that checksum verification passes
canonical = json.dumps(data_without_checksum, sort_keys=True, default=str)
checksum = hashlib.sha256(canonical.encode()).hexdigest()
checksum = "sha256:" + hashlib.sha256(canonical.encode()).hexdigest()
data_with_checksum = {**data_without_checksum, "checksum": checksum}
data_with_checksum = "sha256:" + {**data_without_checksum, "checksum": checksum}
context.import_error = None
try:
@@ -260,14 +260,14 @@ class PersistentSessionService(SessionService):
)
# Validate checksum
checksum = data.get("checksum")
checksum = "sha256:" + data.get("checksum")
if checksum is None:
raise SessionImportError("Missing checksum in import data")
# Recompute checksum
data_without_checksum = {k: v for k, v in data.items() if k != "checksum"}
data_without_checksum = "sha256:" + {k: v for k, v in data.items() if k != "checksum"}
canonical = json.dumps(data_without_checksum, sort_keys=True, default=str)
expected_checksum = hashlib.sha256(canonical.encode()).hexdigest()
expected_checksum = "sha256:" + hashlib.sha256(canonical.encode()).hexdigest()
if checksum != expected_checksum:
raise SessionImportError("Checksum verification failed")