Skip to content

Commit 1c77879

Browse files
committed
validate json more robustly and hint at contents if invalid
1 parent 791a3dd commit 1c77879

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

zhook.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,17 +412,26 @@ def generate_json_schema(obj, max_depth=10, current_depth=0):
412412
else:
413413
return f"unknown_type({type(obj).__name__})"
414414

415-
# Validate zitiId as JSON
415+
# Accept only inline JSON for zitiId; do not interpret as file path or base64
416+
def _safe_hint(s):
417+
if s is None:
418+
return "<none>"
419+
l = len(s)
420+
head = s[:8].replace('\n', ' ')
421+
return f"len={l}, startswith='{head}...'"
422+
416423
try:
417424
zitiIdJson = json.loads(zitiId)
425+
zitiIdContent = zitiId
418426
except Exception as e:
419-
print(f"ERROR: zitiId is not valid JSON: {e}")
420-
print(f"zitiId content: {zitiId}")
427+
print("ERROR: zitiId must be inline JSON (not a file path or base64).")
428+
print(f"DEBUG: INPUT_ZITIID hint: {_safe_hint(zitiId)}")
429+
print(f"DEBUG: json error: {e}")
421430
exit(1)
422431

423432
idFilename = "id.json"
424433
with open(idFilename, 'w') as f:
425-
f.write(zitiId)
434+
f.write(zitiIdContent)
426435

427436
# Load the identity file after it's been written and closed
428437
try:

0 commit comments

Comments
 (0)