fix: address PR #683 review feedback

Critical fixes:
- Remove duplicate core.setFailed() call in parseAndSetStructuredOutputs
  (fixes double error reporting issue)
- Extract JSON schema handling to shared utility function
  (eliminates code duplication between agent/tag modes)

Changes:
- base-action/src/run-claude.ts: Remove redundant setFailed() before throw
- src/utils/json-schema.ts: New shared appendJsonSchemaArg() utility
- src/modes/agent/index.ts: Use shared JSON schema utility
- src/modes/tag/index.ts: Use shared JSON schema utility

All tests passing, types checked, code formatted.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
inigo
2025-11-18 11:55:41 -08:00
parent e600a516c7
commit e93583852d
6 changed files with 27 additions and 21 deletions

View File

@@ -36,10 +36,10 @@ async function run() {
claudeArgs += ` --allowedTools "${process.env.INPUT_ALLOWED_TOOLS}"`;
}
// Add JSON schema if specified
// Add JSON schema if specified (no escaping - parseShellArgs handles it)
if (process.env.JSON_SCHEMA) {
const escapedSchema = process.env.JSON_SCHEMA.replace(/'/g, "'\\''");
claudeArgs += ` --json-schema '${escapedSchema}'`;
// Wrap in single quotes for parseShellArgs
claudeArgs += ` --json-schema '${process.env.JSON_SCHEMA}'`;
}
await runClaude(promptConfig.path, {

View File

@@ -184,13 +184,11 @@ async function parseAndSetStructuredOutputs(
);
if (!result?.structured_output) {
const error = new Error(
throw new Error(
`json_schema was provided but Claude did not return structured_output.\n` +
`Found ${messages.length} messages. Result exists: ${!!result}\n` +
`The schema may be invalid or Claude failed to call the StructuredOutput tool.`,
);
core.setFailed(error.message);
throw error;
}
// Set GitHub Action output for each field