{"record":{"id":"394a7afa1e1d20a4","repo":"huggingface/open-r1","slug":"response","errorCode":null,"errorMessage":"{response}","messagePattern":"\\{response\\}","errorType":"exception","errorClass":"PistonError","httpStatus":null,"severity":"error","filePath":"src/open_r1/utils/competitive_programming/ioi_scoring.py","lineNumber":318,"sourceCode":"\n\nasync def execute_ioi(client, data) -> tuple[str, str]:\n    \"\"\"\n    Requests to the IOI package return the score as a float in the stdout, as well as optional feedback/errors in stderr.\n    Returns a tuple of (score, feedback).\n    \"\"\"\n    response = await client.send_execute(data)\n\n    if \"message\" in response:\n        raise PistonError(response[\"message\"])\n\n    if \"compile\" in response and response[\"compile\"][\"code\"] != 0:\n        return \"0\", \"Compilation error exit code \" + str(response[\"compile\"][\"code\"]) + \"\\n\" + response[\"compile\"][\n            \"stderr\"\n        ]\n\n    if \"run\" not in response:\n        raise PistonError(response)\n\n    if response[\"run\"][\"code\"] == 1 and \"MemoryError\" in response[\"run\"][\"stderr\"]:\n        return \"0\", \"Memory limit exceeded\"\n\n    # successful result\n    if response[\"run\"][\"stdout\"]:\n        return response[\"run\"][\"stdout\"], response[\"run\"][\"stderr\"]\n\n    if response[\"run\"][\"signal\"] == \"SIGKILL\":\n        return \"0\", \"Time limit exceeded\"\n\n    # other issues\n    if response[\"run\"][\"code\"] != 0:\n        raise PistonError(\n            f\"language={response['language']}, version={response['version']}, exit code={response['run']['code']}, stderr={response['run']['stderr']}, signal={response['run']['signal']}\"\n        )\n    return \"0\", \"Unknown error\"\n","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/huggingface/open-r1/blob/1416fa0cf21595d2083b399a2a0bbddd7f6e9563/src/open_r1/utils/competitive_programming/ioi_scoring.py#L300-L336","documentation":"After handling compilation, execute_ioi requires a 'run' key in the Piston response. If the response has no 'run' entry, the whole response object is raised as PistonError, because Piston only omits 'run' when the submission never actually executed (API-level failure, malformed response, or language/version not resolved).","triggerScenarios":"send_execute returns a dict lacking 'run' — typically a Piston error body that happened to carry no top-level 'message' key (e.g. partial/odd response shape from a proxy, or a runtime that failed to install), so the guard on 'message' at line ~310 didn't fire.","commonSituations":"Reverse proxy or load balancer in front of Piston rewriting error bodies; a custom IOI package whose language runtime failed to install on the worker; endpoint version mismatch returning an unexpected schema.","solutions":["Inspect the full response printed in the error — it shows exactly what the endpoint returned and usually reveals the real cause (e.g. 'language cms_ioi not found').","Confirm the endpoint exposes the cms_ioi runtime via GET /api/v2/runtimes; reinstall the IOI package if missing.","Check for proxies/CDNs between client and worker that may strip or reshape the JSON response.","Update the piston client/IOI package if the endpoint's response schema changed."],"exampleFix":"// before: raw response dict in error\nraise PistonError(response)\n// after: log with context\nraise PistonError(f\"No 'run' in Piston response: {json.dumps(response)[:2000]}\")","handlingStrategy":"validation","validationCode":"required = {'compile', 'run'}\nmissing = required - set(response.keys())\nif missing and 'message' not in response:\n    raise RuntimeError(f'Unexpected Piston response shape, missing {missing}: {response}')","typeGuard":"def has_run_result(resp: dict) -> bool:\n    run = resp.get('run') if isinstance(resp, dict) else None\n    return isinstance(run, dict) and 'code' in run","tryCatchPattern":"try:\n    result = await execute_ioi(client, data)\nexcept PistonError as e:\n    if 'cms_ioi not found' in str(e) or \"'run'\" in str(e):\n        await mark_endpoint_unhealthy(endpoint)\n    raise","preventionTips":["Pin the same IOI package/schema version on client and workers","Avoid proxies that rewrite Piston JSON bodies","Assert response schema in an integration test against your real workers"],"tags":["piston","schema-mismatch","sandbox-execution"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"1416fa0cf21595d2083b399a2a0bbddd7f6e9563","analyzedAt":"2026-08-30T08:56:53.400Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}