fix: parse inline --flag=value form in claude_args#1487
Open
HumphreySun98 wants to merge 1 commit into
Open
Conversation
parseClaudeArgsToExtraArgs only handled the space-separated `--flag value` form: it did `flag = arg.slice(2)` without splitting on `=`, so a CLI-valid token like `--allowedTools=Edit,Read` became the bogus extraArg key "allowedTools=Edit,Read" with the value dropped. This bypassed the allowedTools/disallowedTools/add-dir merge and the --json-schema detection that parseSdkOptions keys off exact flag names — silently dropping tools and disabling structured output. Split the flag on the first `=` only (preserving `=` inside values such as inline JSON) and route the inline value through the same accumulating/non-accumulating handling as the space form, so `--flag=value` and `--flag value` are equivalent. Adds regression tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
claude_argswritten in the inline--flag=valueform — which the Claude Code CLI itself accepts — is silently mis-parsed: the flag name and value are never split, so the whole token becomes a bogusextraArgskey and the value is dropped.Why it matters
parseClaudeArgsToExtraArgs(base-action/src/parse-sdk-options.ts) doesconst flag = arg.slice(2)and never splits on=. So--allowedTools=Edit,Readbecomes the key"allowedTools=Edit,Read"(valuenull) instead ofallowedTools → "Edit,Read". Downstream,parseSdkOptionskeys its interception/merge/detection off exact flag names, so with the=form:--allowedTools=/--disallowedTools=/--add-dir=are not merged intosdkOptions— the tools/dirs are silently dropped, and the rawallowedTools=…token leaks through to the CLI as a malformed flag (reintroducing the duplicate---allowedToolsclobbering that --allowed-tools parsing broken after USE_AGENT_SDK default changed to true (PR #738) #746 hardened against).--json-schema={…}is not detected —hasJsonSchemastaysfalse, so structured output is silently skipped.Reproduced on current
main:Fix
In the arg loop, split the flag on the first
=only (so a value that itself contains=, e.g. inline JSON, is preserved) and route the inline value through the same accumulating / non-accumulating handling used for the space-separated form.--flag=valueand--flag valuenow produce identical results, and--flag=valueconsumes no following token (matching CLI semantics).Tests
Added a
--flag=value (inline value) formsuite tobase-action/test/parse-sdk-options.test.ts: the=-formallowedToolsequals the space form;--json-schema=…setshasJsonSchema; split-on-first-=preserves=inside the value;disallowedTools/add-dirwork; and repeated--allowedTools=…accumulate. Each fails before the fix and passes after.Verification
bun test→ 774 pass, 0 fail (5 new).bun run typecheck→ clean.bun run format:check→ clean.