Bug Description
When settingSources is not explicitly provided to query(), the SDK passes --setting-sources "" (empty string) to the Claude Code CLI. The CLI argument parser then consumes the next flag (--permission-mode) as the setting source value, producing:
Error processing --setting-sources: Invalid setting source: --permission-mode. Valid options are: user, project, local
This blocks all default usage of the SDK — any query() call without explicit settingSources fails.
Version
@anthropic-ai/claude-agent-sdk@0.2.84, Claude Code CLI 2.1.84
Reproduction
import { query } from '@anthropic-ai/claude-agent-sdk';
// Simplest possible call — no settingSources configured
for await (const msg of query('Say hello')) {
console.log(msg.type);
}
// → Error: Invalid setting source: --permission-mode
Expected Behavior
When settingSources is not provided, the SDK should not pass --setting-sources to the CLI at all — matching the behavior of other array-typed flags like --betas, --allowedTools, and --disallowedTools, which are correctly omitted when their arrays are empty.
Workaround
for await (const msg of query('Say hello', { settingSources: ['user'] })) {
console.log(msg.type);
}
Explicitly providing a non-empty settingSources avoids the empty-string argument.
Additional Context
- The
client() constructor appears to have the same issue (hardcoded empty settingSources array)
Bug Description
When
settingSourcesis not explicitly provided toquery(), the SDK passes--setting-sources ""(empty string) to the Claude Code CLI. The CLI argument parser then consumes the next flag (--permission-mode) as the setting source value, producing:This blocks all default usage of the SDK — any
query()call without explicitsettingSourcesfails.Version
@anthropic-ai/claude-agent-sdk@0.2.84, Claude Code CLI2.1.84Reproduction
Expected Behavior
When
settingSourcesis not provided, the SDK should not pass--setting-sourcesto the CLI at all — matching the behavior of other array-typed flags like--betas,--allowedTools, and--disallowedTools, which are correctly omitted when their arrays are empty.Workaround
Explicitly providing a non-empty
settingSourcesavoids the empty-string argument.Additional Context
client()constructor appears to have the same issue (hardcoded emptysettingSourcesarray)