From b61dc0f5e500d2c07d36d7441106d66dc83f7350 Mon Sep 17 00:00:00 2001 From: ggman12 Date: Wed, 18 Feb 2026 17:08:43 -0500 Subject: [PATCH] provide more error --- src/contributions/schema.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/contributions/schema.py b/src/contributions/schema.py index e2ee54b..54fa5e1 100644 --- a/src/contributions/schema.py +++ b/src/contributions/schema.py @@ -219,7 +219,19 @@ def parse_and_validate(json_str: str, schema: dict | None = None) -> tuple[list try: data = json.loads(json_str) except json.JSONDecodeError as e: - return None, [f"Invalid JSON: {e}"] + # Provide detailed error context + error_msg = f"Invalid JSON: {e}" + + # Show context around the error position + if hasattr(e, 'pos') and e.pos is not None: + start = max(0, e.pos - 50) + end = min(len(json_str), e.pos + 50) + context = json_str[start:end] + # Escape for readability + context_escaped = repr(context) + error_msg += f"\n\nContext around position {e.pos}: {context_escaped}" + + return None, [error_msg] errors = validate_submission(data, schema) return data, errors