Skip to content

fix: use is not None for betas and plugins to distinguish unset from empty#803

Open
FuturizeRush wants to merge 1 commit intoanthropics:mainfrom
FuturizeRush:fix/truthiness-betas-plugins
Open

fix: use is not None for betas and plugins to distinguish unset from empty#803
FuturizeRush wants to merge 1 commit intoanthropics:mainfrom
FuturizeRush:fix/truthiness-betas-plugins

Conversation

@FuturizeRush
Copy link
Copy Markdown

Summary

Fix two remaining truthiness bugs in subprocess_cli.py — same class as #634 (tools, fixed) and #778 (setting_sources, fixed).

Bug

_build_command() uses truthiness checks for betas and plugins, making empty lists indistinguishable from None (unset):

if self._options.betas:     # betas=[] is falsy → --betas never sent
if self._options.plugins:   # plugins=[] is falsy → --plugin-dir never sent

Compare with the already-fixed tools field on line 185:

if self._options.tools is not None:  # Correct: [] sends --tools ""

Fix

  • betas: is not None + empty list sends --betas ""
  • plugins: is not None (empty list = no plugins, loop body doesn't execute)

Follows the same pattern established by the tools fix.

Test plan

  • betas=None → no --betas flag (unchanged)
  • betas=[]--betas "" (fixed — was silently skipped)
  • betas=["beta1"]--betas beta1 (unchanged)
  • plugins=None → no --plugin-dir flags (unchanged)
  • plugins=[] → no --plugin-dir flags, but loop entered (fixed — was silently skipped)

…m empty

Same class of bug as anthropics#634 (tools) and anthropics#778 (setting_sources).

`betas=[]` means "disable all betas" but the truthiness check
treats [] as falsy, so --betas is never passed to the CLI.

`plugins=[]` means "no plugins" but [] is falsy, so plugin dirs
are never passed.

The `tools` field was already fixed to use `is not None` (line 185).
This aligns `betas` and `plugins` with the same pattern.
IgorTavcar added a commit to IgorTavcar/claude-agent-sdk-python that referenced this pull request Apr 10, 2026
- anthropics#806: setting_sources=[] truthiness fix
- anthropics#803: betas=[]/plugins=[] truthiness fix
- anthropics#786: ThinkingBlock missing signature crash fix
- anthropics#790: suppress ProcessError when result already received
- anthropics#658: capture real stderr in ProcessError
- anthropics#791: suppress stale task notifications between turns
- anthropics#763: guard malformed CLAUDE_CODE_STREAM_CLOSE_TIMEOUT env var
- anthropics#805: delete_session() cascades subagent transcript dir
- anthropics#804: top-level skills option on ClaudeAgentOptions
- anthropics#691: PostCompact hook event type support

479 tests passing, mypy clean, ruff clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant