openedx / openedx/openedx-platform

Codejail execution raises error if NaN or Infinity in returned globals_dict

Open
#36,575 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.2k
Forks
4.4k
Avg merge
6d 18h
Merged PRs (30d)
42

Description

Running out = float("NaN") in a custom Python-evaluated problem causes an error in both local and remote codejail execution:

  • Local safe exec fails with: JSONDecodeError('Expecting value: line 1 column 970 (char 969)')
  • Remote exec fails with: CodejailServiceParseError('Invalid JSON response received from codejail api service.')

Notes:

  • There are two places where globals pass through JSON: The codejail library's own serialization for passing data to and from a subprocess, and the HTTP call (for remote exec). The error could be coming from one or both places, and either the sending or receiving direction.
  • The JSON RFC does not provide a way to include NaN and Infinity, but some JSON implementations break with this to provide full float support.
    • Python's json module parses and formats JSON with these values by default, controllable with allow_nan.
    • DRF sets allow_nan=False by default, but setting REST_FRAMEWORK.STRICT_JSON = False overrides this. We've already made this fix in https://github.com/openedx/codejail-service/pull/48 so the remaining issues should all be in edxapp itself.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the local and remote codejail executions described in the issue, then trace JSON serialization in the subprocess and HTTP paths to identify whether sending or receiving rejects NaN and Infinity. Done means custom Python-evaluated problems return globals containing these values successfully in both local and remote execution.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.