Fix Wrong Answer for problems with top-level JSON string output - #15
Open
alexandramartinez wants to merge 1 commit into
Open
Fix Wrong Answer for problems with top-level JSON string output#15alexandramartinez wants to merge 1 commit into
alexandramartinez wants to merge 1 commit into
Conversation
The execute proxy returned the backend's decoded `output` value verbatim when it was a string, so a top-level JSON string lost its surrounding quotes (e.g. `Alice, Bob, Carol` instead of `"Alice, Bob, Carol"`). The submit comparison then re-serialized the quoted expected value but kept the unquoted actual value, making any string-output problem unsolvable. Serialize based on the script's declared `output` format: JSON output is always JSON.stringify'd (so strings keep their quotes), while non-JSON formats (csv, xml, ...) pass their already-rendered text through unchanged. Fixes bighnesh0007#12 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@alexandramartinez is attempting to deploy a commit to the bighnesh's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Fixes #12 — problems whose expected output is a top-level JSON string (e.g.
concatenate-employee-names) were impossible to solve. Submit always returned "Wrong Answer" because the actual output was shown with its surrounding quotes stripped, so it never matched the quoted expected value.Root cause
The backend at
dwlbackend.onrender.comreturnsoutputas the decoded value, not serialized text:application/json→ a real JSON value ({"output":"Alice, Bob, Carol"},{"output":3},{"output":{...}})application/csv, xml, …) → the already-rendered text as a stringThe proxy in
app/api/execute/route.tsdidtypeof value === "string" ? value : JSON.stringify(value), so a top-level JSON string was passed through unquoted. The submit comparison inWorkspace.tsxthen re-serialized the quoted expected value but kept the unquoted actual value — never equal.Fix
Serialize based on the script's declared
outputformat:JSON.stringifythe value, so a top-level string keeps its quotes ("Alice, Bob, Carol").Verification
Tested end-to-end against a local dev server with the real problem seeded into MongoDB, driving the actual
/api/executeroute and the realnormalize()comparison fromWorkspace.tsx:Before (reproduces the bug):
After:
No regressions confirmed against live backend responses:
"Alice, Bob, Carol"(quoted) ✓3✓a,b\n1,2(raw, no quotes) ✓npx tsc --noEmitpasses clean.🤖 Generated with Claude Code