Skip to contentView the source on GitHub

require-action-input-schema

Validate untrusted Astro Action input before the handler runs.

Securitywarning by default Project auditrecommended audit

astro-doctor/require-action-input-schema

Why it matters

Astro Actions are public endpoints. An input schema rejects malformed or unexpected request data before it reaches application logic and gives the handler typed input.

See the difference

Incorrect

Handler consumes input without validation

typescriptIncorrect example
export const server = {
  createUser: defineAction({
    handler: async (input) => createUser(input),
  }),
}

Correct

Validate input with a schema

typescriptCorrect example
import { z } from 'astro:schema'

export const server = {
  createUser: defineAction({
    input: z.object({
      email: z.string().email(),
    }),
    handler: async ({ email }) => createUser({ email }),
  }),
}

Configure this check

Project audits are configured in doctor.config.ts:

typescriptdoctor.config.ts
export default {
  rules: {
    'astro-doctor/require-action-input-schema': 'error',
  },
}

Use 'error', 'warn', or 'off'. The configuration guide covers presets and per-file overrides.

Keep exploring security

Browse every rule and project audit