From 5c08a8629120cfdd6d63f581aec8d5b03282e20b Mon Sep 17 00:00:00 2001 From: Yohei Demachi <55367533+yoheidemachi@users.noreply.github.com> Date: Sun, 1 Mar 2026 10:56:47 +0900 Subject: [PATCH 1/2] Fix shell-quote treating # as comment in claude_args values shell-quote's parse() returns {comment: "..."} objects when it encounters # characters, even inside flag values. The existing filter dropped these objects, causing the flag to receive a null value and triggering an AJV schema validation crash. Convert comment objects back to strings (prepending #) instead of dropping them, so values like "# Use best practices" are preserved. Fixes #980 Co-Authored-By: Claude Opus 4.6 --- base-action/src/parse-sdk-options.ts | 14 +++++++++--- base-action/test/parse-sdk-options.test.ts | 26 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/base-action/src/parse-sdk-options.ts b/base-action/src/parse-sdk-options.ts index 35df281d2..890e053db 100644 --- a/base-action/src/parse-sdk-options.ts +++ b/base-action/src/parse-sdk-options.ts @@ -92,9 +92,17 @@ function parseClaudeArgsToExtraArgs( if (!claudeArgs?.trim()) return {}; const result: Record = {}; - const args = parseShellArgs(claudeArgs).filter( - (arg): arg is string => typeof arg === "string", - ); + const args = parseShellArgs(claudeArgs) + .map((arg) => { + if (typeof arg === "string") return arg; + // shell-quote treats # as a comment and returns {comment: "..."} objects. + // Convert these back to strings since # is valid in flag values. + if (typeof arg === "object" && arg !== null && "comment" in arg) { + return `#${(arg as { comment: string }).comment}`; + } + return undefined; + }) + .filter((arg): arg is string => arg !== undefined); for (let i = 0; i < args.length; i++) { const arg = args[i]; diff --git a/base-action/test/parse-sdk-options.test.ts b/base-action/test/parse-sdk-options.test.ts index 9c1095cef..ffd8fca3b 100644 --- a/base-action/test/parse-sdk-options.test.ts +++ b/base-action/test/parse-sdk-options.test.ts @@ -298,6 +298,32 @@ describe("parseSdkOptions", () => { }); }); + describe("hash character handling", () => { + test("should preserve # in flag values instead of treating as comment", () => { + const options: ClaudeOptions = { + claudeArgs: '--append-system-prompt "# Use best practices"', + }; + + const result = parseSdkOptions(options); + + expect(result.sdkOptions.extraArgs?.["append-system-prompt"]).toBe( + "# Use best practices", + ); + }); + + test("should handle unquoted # by converting comment object back to string", () => { + const options: ClaudeOptions = { + claudeArgs: "--model claude-sonnet-4-5-20250929 --append-system-prompt #Use", + }; + + const result = parseSdkOptions(options); + + expect(result.sdkOptions.extraArgs?.["append-system-prompt"]).toBe( + "#Use", + ); + }); + }); + describe("other extraArgs passthrough", () => { test("should pass through json-schema in extraArgs", () => { const options: ClaudeOptions = { From 987c56b2d9d457d1397bd10b6c90164b134d58ad Mon Sep 17 00:00:00 2001 From: Yohei Demachi <55367533+yoheidemachi@users.noreply.github.com> Date: Sun, 1 Mar 2026 11:09:52 +0900 Subject: [PATCH 2/2] style: fix Prettier formatting in test file Co-Authored-By: Claude Opus 4.6 --- base-action/test/parse-sdk-options.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/base-action/test/parse-sdk-options.test.ts b/base-action/test/parse-sdk-options.test.ts index ffd8fca3b..08a7f3221 100644 --- a/base-action/test/parse-sdk-options.test.ts +++ b/base-action/test/parse-sdk-options.test.ts @@ -313,7 +313,8 @@ describe("parseSdkOptions", () => { test("should handle unquoted # by converting comment object back to string", () => { const options: ClaudeOptions = { - claudeArgs: "--model claude-sonnet-4-5-20250929 --append-system-prompt #Use", + claudeArgs: + "--model claude-sonnet-4-5-20250929 --append-system-prompt #Use", }; const result = parseSdkOptions(options);