Skip to content

fix(api): frontmatter validation errors are actionable (#649)#672

Merged
chronoai-shining merged 1 commit into
developfrom
fix/649-frontmatter-validation-messages
May 21, 2026
Merged

fix(api): frontmatter validation errors are actionable (#649)#672
chronoai-shining merged 1 commit into
developfrom
fix/649-frontmatter-validation-messages

Conversation

@chronoai-shining
Copy link
Copy Markdown
Collaborator

Summary

The Free / ZIP upload page already shows clear actionable messages for most validation failures (version semver, tag regex, env-var UPPER_SNAKE rule), but the tag, runtime, tool-list, runtime-env-var, and runtime-dependency item schemas surfaced as bare Invalid input: expected string, received null when an author hit common YAML traps:

  • tag: - (empty list-item dash) → YAML parses as null
  • version: 0.1 (unquoted) → YAML parses as a number (this one was already handled in an earlier pass; pinned with a test here so it can't regress)

Fix

Each item schema gets a Zod 4 error: (issue) => ... callback that intercepts invalid_type with a sentence including a concrete shape example (tag: [my-tag], runtime: [python], runtime-env-var: [OPENAI_API_KEY], etc.). Existing min/max/regex messages still fire for non-null shape failures.

Test plan

  • New skillFrontmatter.test.ts — 8 assertions (version quoting, null tag, uppercase tag (regex preservation), null env-var, null runtime, null tool, null dep, happy-path)
  • bun test — 805/805 pass; typecheck clean
  • CI green
  • Reproduce on local cluster after deploy: upload ZIP with version: 0.1 and ZIP with tag: [-] — both now show actionable messages

Closes #649.

The Free / ZIP upload page already shows clear messages for most
validation failures (version semver, tag regex, env-var UPPER_SNAKE
rule), but the `tag`, `runtime`, `tool-list`, `runtime-env-var`, and
`runtime-dependency` ITEM schemas surfaced as bare `Invalid input:
expected string, received null` when an author hit common YAML traps:

  - `tag: - ` (empty list-item dash) → YAML parses as `null`
  - `version: 0.1` (unquoted) → YAML parses as a number (this one was
    already handled in an earlier pass; pinned with a test so it
    can't regress)

Each item schema in `shared/schemas/skillFrontmatter.ts` now carries
a Zod 4 `error: (issue) => ...` callback that intercepts
`invalid_type` with a sentence including a concrete shape example,
e.g.:

  - tag → `tag: [my-tag]`
  - runtime → `runtime: [python]`
  - runtime-env-var → `runtime-env-var: [OPENAI_API_KEY]`
  - tool-list → `tool-list: [Bash, Read]`
  - runtime-dependency → `runtime-dependency: [requests==2.31]`

Existing min / max / regex messages still fire for non-null shape
failures so uppercase tags etc. keep their current friendly text.

Pinned with skillFrontmatter.test.ts — 8 assertions covering
version-quoting, null-tag, uppercase-tag (regex preservation), null
env-var, null runtime, null tool, null dependency, and a happy-path
round trip. Full ornn-api: 805/805 tests pass, typecheck clean.

Closes #649.
@chronoai-shining chronoai-shining merged commit 4a34183 into develop May 21, 2026
11 checks passed
@chronoai-shining chronoai-shining deleted the fix/649-frontmatter-validation-messages branch May 21, 2026 08:49
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.

[Bug] [Skill Upload] Some frontmatter validation errors only show generic Invalid input

1 participant