Skip to content

[BUG] Empty settingSources array causes --setting-sources "" to consume next CLI flag #252

@nick-inkeep

Description

@nick-inkeep

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions