Skip to content

fix(core): add additional spec-validator checks for common LLM errors#215

Open
nil957 wants to merge 1 commit intovercel-labs:mainfrom
nil957:fix/spec-validator-additional-checks
Open

fix(core): add additional spec-validator checks for common LLM errors#215
nil957 wants to merge 1 commit intovercel-labs:mainfrom
nil957:fix/spec-validator-additional-checks

Conversation

@nil957
Copy link

@nil957 nil957 commented Mar 13, 2026

Summary

Extends validateSpec and autoFixSpec to detect and repair more common AI-generation mistakes.

New Validation Checks

Code Description
action_in_props Legacy action prop placed inside props
actionParams_in_props Legacy actionParams placed inside props
children_in_props Children array placed inside props instead of element level
state_in_props State object placed inside element props

Example: action_in_props

// ❌ Wrong (LLM-generated)
{
  "type": "Button",
  "props": { "label": "Submit", "action": "save", "actionParams": { "id": 1 } }
}

// ✅ Correct
{
  "type": "Button",
  "props": { "label": "Submit" },
  "on": { "press": { "action": "save", "params": { "id": 1 } } }
}

Example: children_in_props

// ❌ Wrong
{
  "type": "Stack",
  "props": { "children": ["a", "b"] }
}

// ✅ Correct
{
  "type": "Stack",
  "props": {},
  "children": ["a", "b"]
}

Auto-Fix Enhancements

autoFixSpec now automatically repairs:

  1. children in props → moves to element level
  2. Legacy action/actionParams → converts to on.press binding

Motivation

LLMs frequently make these mistakes because:

  • action/actionParams was a pattern from earlier versions
  • children feels like a natural prop name
  • React's props.children pattern is well-known

Better detection + auto-fix improves the success rate of AI-generated specs.

Checklist

  • Tests added for new validation codes
  • Tests added for auto-fix cases
  • No breaking changes
  • Error messages include guidance on correct structure

Adds detection for more common AI-generation mistakes:

- `action_in_props`: Legacy action prop (should use on.press)
- `actionParams_in_props`: Legacy actionParams (should use on.press)
- `children_in_props`: Children array placed inside props
- `state_in_props`: State object placed inside element props

Also extends autoFixSpec to automatically repair:
- `children` in props → moves to element level
- Legacy `action`/`actionParams` → converts to `on.press` binding

These patterns are frequently generated by LLMs that don't fully
understand the flat spec structure.
@vercel
Copy link
Contributor

vercel bot commented Mar 13, 2026

Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant