Skip to content

fix(python): fix CodeBox(memory_mib=...) crash due to positional arg mismatch#245

Merged
DorianZheng merged 1 commit intomainfrom
fix/codebox-positional-args
Feb 13, 2026
Merged

fix(python): fix CodeBox(memory_mib=...) crash due to positional arg mismatch#245
DorianZheng merged 1 commit intomainfrom
fix/codebox-positional-args

Conversation

@yingjunwu
Copy link
Copy Markdown
Contributor

Summary

  • Fix CodeBox.__init__ passing positional args to SimpleBox.__init__, which has rootfs_path as the 2nd parameter — causing memory_mib to map to rootfs_path

Test plan

  • CodeBox(memory_mib=1024) no longer crashes with TypeError
  • CodeBox(cpus=2) correctly sets CPU count instead of silently misassigning

Closes #228

🤖 Generated with Claude Code

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug in CodeBox.__init__ where positional arguments were being passed to SimpleBox.__init__, causing parameter misalignment. The SimpleBox parent class has a rootfs_path parameter between image and memory_mib that CodeBox doesn't have, causing all subsequent positional arguments to shift incorrectly (e.g., memory_mib=1024 was being interpreted as rootfs_path=1024, leading to a TypeError).

Changes:

  • Changed CodeBox.__init__ to pass keyword arguments to super().__init__() instead of positional arguments
  • This aligns CodeBox with the convention used by all other SimpleBox subclasses in the codebase

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yingjunwu
Copy link
Copy Markdown
Contributor Author

Self-review: This PR looks correct.

The bug: CodeBox.__init__ passed args positionally to SimpleBox.__init__, but SimpleBox has rootfs_path as the 2nd parameter. So memory_mib was being passed as rootfs_path, cpus as memory_mib, etc.

The fix switches to keyword arguments, which maps correctly regardless of parameter order.

No other callers affected — SyncCodeBox.__init__ already uses keyword args.

CodeBox.__init__ passed arguments positionally to super().__init__(),
but SimpleBox has rootfs_path as the 2nd parameter. This caused
memory_mib to map to rootfs_path, cpus to memory_mib, etc.

CodeBox(memory_mib=1024) crashed with:
  TypeError: argument 'rootfs_path': 'int' object cannot be cast as 'str'

Fix: pass keyword arguments so parameters map correctly regardless
of SimpleBox's parameter order.

Closes #228

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@yingjunwu yingjunwu force-pushed the fix/codebox-positional-args branch from 449d83f to c1e54d5 Compare February 13, 2026 02:13
@DorianZheng DorianZheng merged commit 405f7c2 into main Feb 13, 2026
19 checks passed
@DorianZheng DorianZheng deleted the fix/codebox-positional-args branch February 13, 2026 02:49
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.

CodeBox(memory_mib=...) crashes due to positional arg mismatch with SimpleBox

3 participants