Skip to content

feat!: clean up after the local codejail removal - #39429

Open
feanil wants to merge 4 commits into
openedx:masterfrom
feanil:feanil/codejail-cleanup
Open

feanil wants to merge 4 commits into
openedx:masterfrom
feanil:feanil/codejail-cleanup

Conversation

@feanil

@feanil feanil commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #39382. Closes #39427.

  • Removes the debug run_python view and the ENABLE_DEBUG_RUN_PYTHON setting. The platform no longer runs codejail itself, so the page doesn't test anything the platform owns.
  • Removes the xmodule.capa.safe_exec.remote_exec shim, which has warned since Verawood. A CODE_JAIL_REST_SERVICE_REMOTE_EXEC setting that still points at it, or at the xblocks_contrib.problem.capa... path the Verawood warning suggested, keeps working: xblocks-core falls back to the default sender when it can't import the configured one. What breaks is code that imports the module directly.
  • Stops reading COURSES_WITH_UNSAFE_CODE. feat!: remove local codejail #39382 removed its default and docs, but can_execute_unsafe_code still read it, so a course left on the list failed every Python-evaluated problem. The module-level can_execute_unsafe_code is gone. The deprecated runtime.can_execute_unsafe_code properties stay and always return False, so XBlocks that still read them don't break. SandboxService.can_execute_unsafe_code stays as a shim that always returns False, because xblocks-core's ProblemBlock still reads it; Drop can_execute_unsafe_code and the unsafely argument xblocks-core#350 tracks removing it.
  • Drops edx-sandbox from the requirements README and the comment in the consistent-dependencies workflow.

All three removals are breaking, and each commit carries a BREAKING CHANGE footer. They'll go in the Willow operator notes next to the local codejail removal.

The /debug/run_python page let staff run Python through the sandbox to
check that codejail was set up on the server.  Since openedx#39382 the platform
no longer runs codejail itself; it only calls codejail-service, which has
its own health checks, so the page no longer tests anything the platform
owns.

Removes the view, its URL and template, and the ENABLE_DEBUG_RUN_PYTHON
setting that turned it on.

Closes part of openedx#39427
See openedx#36639

BREAKING CHANGE: The ENABLE_DEBUG_RUN_PYTHON setting and the
/debug/run_python page are removed.  Remove the setting from your
configuration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@feanil
feanil marked this pull request as ready for review November 24, 2026 16:53
@feanil
feanil requested a review from MoisesGSalas November 24, 2026 16:53
@feanil feanil mentioned this pull request Nov 24, 2026
5 tasks done

@MoisesGSalas MoisesGSalas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good.

@ormsbee ormsbee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small things inline. The one I'd like sorted out before this merges is the shim's BREAKING CHANGE footer, since I don't think a stale CODE_JAIL_REST_SERVICE_REMOTE_EXEC actually breaks after this. I also have a question about whether we can be more aggressive about removing calls to can_execute_unsafe_code(), but I don't consider that blocking.


Claude usage details

Claude drafted this review and ran these on 4e50a6a:

  • Throwaway test of get_remote_exec() with stale settings (xblocks-core 3.0.0, lms.envs.test): passed. Not in the branch.
    • CODE_JAIL_REST_SERVICE_REMOTE_EXEC set to the old xmodule path, the xblocks_contrib path from the Verawood warning, and a made-up my_plugin path, with send_safe_exec_request_v0 mocked.
    • Each one called the mocked default sender once, with no warnings and no log records. A real module with a missing function raised AttributeError.
  • test_sandboxing.py, plus the unsafe_code tests in test_block_render.py and test_preview.py (Python 3.12, SQLite, MongoDB 7.0): 18 passed.
  • git grep for run_python, ENABLE_DEBUG_RUN_PYTHON, xmodule.capa.safe_exec and requirements/edx-sandbox: only a #: source reference in conf/locale/eo/LC_MESSAGES/django.po.
  • Shim history: cd733fe (#38045) is in release/verawood and not in release/ulmo.
  • Read the Docs check: the build was cancelled after about a minute, as were eight of the fifteen builds after it, so it doesn't look related to this branch.

Model: Claude Fable 5.2 (claude-fable-5-2)

)

# Wildcard import to expose send_safe_exec_request_v0 and any other attributes
from xblock_problem.capa.safe_exec.remote_exec import * # noqa: F403

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really breaking for the setting? Claude ran get_remote_exec() on this branch with CODE_JAIL_REST_SERVICE_REMOTE_EXEC still pointing at xmodule.capa.safe_exec.remote_exec.send_safe_exec_request_v0, and the call went to the default send_safe_exec_request_v0 anyway, with no warning and nothing logged. xblocks-core catches the ModuleNotFoundError and falls back to the default. The xblocks_contrib.problem.capa... path that the Verawood copy of this shim told people to switch to gets the same treatment.

So as far as I can tell, a stale setting keeps working after this, and what actually breaks is code that imports this module directly. Could you please reword the BREAKING CHANGE footer and the Willow note to say that? It'd be worth naming both old paths, since anyone who followed the Verawood warning has the xblocks_contrib one.

FWIW, I'd rather that fallback at least logged a warning, since a typo in the path to a custom function gets the default sender in the same silent way. But that's an xblocks-core change, and I don't want to add it to the scope of this PR.

Comment thread xmodule/util/sandboxing.py Outdated
Returns a boolean, true if the course can run outside the sandbox.
Returns a boolean, true if the course matches COURSES_WITH_UNSAFE_CODE.

See the module-level `can_execute_unsafe_code` for what a match does now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other two can_execute_unsafe_code docstrings still describe the old behavior. The one on _ModuleSystemShim says it's "whether or not to allow the execution of unsafe, unsandboxed code", and the one on RuntimeShim has a "Change this if/when we need to support unsafe courses in the new runtime" comment. If we're keeping this behavior, those docstrings should probably be updated. But again, I'd be in favor of just removing calls where we can and hardcoding a False return in places where that might break XBlock backwards compatibility.

Comment thread xmodule/util/sandboxing.py Outdated
Comment on lines +22 to +26
Running course code outside the sandbox is no longer supported. When this returns
True, xblocks-core raises ImproperlyConfigured instead of running the course's Python,
so a matching course fails rather than running unsandboxed. Per-course limits are
configured on the codejail service instead.
See https://github.com/openedx/openedx-platform/issues/36639

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Can we just kill this function entirely and update its callers to not call it, now that the question of "can I execute this unsafely" is always "no"? I think that the way this function has been re-purposed to "did you specify that you wanted to escape the sandbox for this course" is going to be confusing, and I'm not clear on what value it adds to have that distinction.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, this was a cleanup miss, once #39382 removed the setting's default we should have dropped every read of it. I removed the module-level function and both runtime.can_execute_unsafe_code properties. The method on SandboxService has to stay for now since xblocks-core's ProblemBlock still reads it, so it just returns False until openedx/xblocks-core#350 lands.

@ormsbee ormsbee Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I think the runtime service and xmodule shim can stay and just always return False. It costs very little, and there's the possibility that there is some XBlock out there in the wild that uses it. I'd just delete it entirely from this module because I wouldn't expect XBlocks in the wild to ever import from xmodule.util.sandboxing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, that makes sense. I put both runtime properties back and they always return False now.

The shim was added in openedx#38045 when capa moved to xblocks-core, so that
deployments with CODE_JAIL_REST_SERVICE_REMOTE_EXEC pointing at the old
module path kept working.  It has warned since Verawood, and the default
already points at the new path.

Closes part of openedx#39427
Shim added in openedx#38045

BREAKING CHANGE: the xmodule.capa.safe_exec.remote_exec module is gone,
so code that imports it directly breaks.  A
CODE_JAIL_REST_SERVICE_REMOTE_EXEC setting that still points at
xmodule.capa.safe_exec.remote_exec.send_safe_exec_request_v0, or at
xblocks_contrib.problem.capa.safe_exec.remote_exec.send_safe_exec_request_v0
as the Verawood warning suggested, keeps working: xblocks-core can't
import it and falls back to the default sender.  Remove the override,
or point it at
xblock_problem.capa.safe_exec.remote_exec.send_safe_exec_request_v0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@feanil
feanil force-pushed the feanil/codejail-cleanup branch from 4e50a6a to cd7ff49 Compare November 25, 2026 02:29
feanil and others added 2 commits November 25, 2026 13:01
still read it with getattr, so a course an operator left on the list made
xblocks-core raise ImproperlyConfigured for every Python-evaluated problem
in it, including ones that run fine in the sandbox.  A removed setting
should just be ignored.

Drop the module-level can_execute_unsafe_code and the setting read.  The
runtime.can_execute_unsafe_code properties on the module system and
runtime shims stay and always return False, so XBlocks that still read
them don't break.  The platform's own ProblemBlock passes lambda: False to
LoncapaSystem.  SandboxService.can_execute_unsafe_code stays as a shim
that always returns False, because xblocks-core's ProblemBlock still reads
it from the sandbox service; it goes with
openedx/xblocks-core#350

Closes part of openedx#39427
See openedx#36639

BREAKING CHANGE: COURSES_WITH_UNSAFE_CODE is no longer read.  Courses
that matched it run their Python in the codejail service like every
other course, instead of failing with ImproperlyConfigured.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
openedx#39382 removed requirements/edx-sandbox; the sandbox's packages are
defined in codejail-service now.  The requirements README and the comment
in the consistent-dependencies workflow still described it.  The workflow
still needs to watch requirements/ for the requirements/edx/*.txt exports,
so only the comment changes.

Closes part of openedx#39427

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@feanil
feanil force-pushed the feanil/codejail-cleanup branch from cd7ff49 to a11d273 Compare November 25, 2026 18:01
@feanil
feanil requested a review from ormsbee November 25, 2026 18:05

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up after the local codejail removal

3 participants