anthropics / anthropics/claude-code-action

feat: expose SDK input schema so action can sanitize settings before validation

Open
#1,021 1 comment 0 reactions 0 assignees View on GitHub
enhancement feature-request p2
Dominant language
TypeScript
Stars
8.9k
Forks
2.1k
Avg merge
3d 9h
Merged PRs (30d)
10

Description

## Problem

The recurring AJV validation crashes (#852, #872, #892, #902, #947, #965, #980, #1013) share a common root cause: the action constructs a settings/config object and passes it to `@anthropic-ai/claude-agent-sdk`, which then runs AJV hard validation on it. When the SDK schema and the action's assumptions drift — which happens on every SDK version bump — the validation crashes before any API call is made.

The action cannot fix this on its own because the schema lives inside the private `claude-agent-sdk` package. Every SDK release is a potential silent breaking change.

## Proposed Solution

If the SDK exposed its input schema (e.g. via a named export like `getSettingsSchema()` or `SETTINGS_SCHEMA`), the action could:

1. Query the schema at runtime
2. Pick only the fields the schema declares as known
3. Pass the sanitized object to the SDK

```ts
// Pseudocode
import { getSettingsSchema } from '@anthropic-ai/claude-agent-sdk';

const schema = getSettingsSchema();
const knownFields = Object.keys(schema.properties);
const sanitizedSettings = pick(rawSettings, knownFields);

// AJV validation now always passes — only declared fields are sent
runClaude(sanitizedSettings);
```

The SDK remains the single source of truth for what it accepts. The action adapts automatically to schema changes without hardcoding field lists or breaking on version bumps.

## Why Not Just Fix the Action?

The action has no way to know what the SDK schema looks like without either:
- Hardcoding assumptions (which drift), or
- The SDK exposing the schema (this proposal)

## Alternative (Simpler)

If exposing the schema is too invasive, the SDK could simply set `additionalProperties: true` on its input schema — unknown fields would be ignored rather than causing a crash. This is the more defensive posture for an internal API between two packages you control.

## Impact

This would eliminate an entire class of P1 regressions that have been recurring since at least September 2025 across multiple issues with no permanent fix.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how the action constructs settings before calling @anthropic-ai/claude-agent-sdk and inspect the SDK's input schema and the runClaude entry point described here. Compare the recurring validation failures, then define whether completion means exposing a runtime schema for sanitization or accepting unknown fields, with validation surviving SDK version changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.