pieceFrontMatterFromPrompt does not validate output against the requested schema #85

Closed
opened 2026-09-26 12:41:41 +00:00 by eleith · 0 comments
Owner

pieceFrontMatterFromPrompt(apiKey, schema, prompt) passes schema to Gemini as responseJsonSchema, then returns JSON.parse(result.text || '{}') without checking it against that schema.

Structured output makes types reliable, but it does not guarantee:

  • keywords Gemini does not support or ignores (minLength, pattern, custom formats),
  • required fields being present (empty output becomes {}; nulls are stripped),
  • that the result is an object at all.

Expected
Validate the parsed result against the requested schema (core already has compile) and throw a descriptive error on mismatch, so callers do not each need their own AJV validation. Related: #77.

`pieceFrontMatterFromPrompt(apiKey, schema, prompt)` passes `schema` to Gemini as `responseJsonSchema`, then returns `JSON.parse(result.text || '{}')` without checking it against that schema. Structured output makes types reliable, but it does not guarantee: - keywords Gemini does not support or ignores (`minLength`, `pattern`, custom `format`s), - required fields being present (empty output becomes `{}`; `null`s are stripped), - that the result is an object at all. **Expected** Validate the parsed result against the requested schema (core already has `compile`) and throw a descriptive error on mismatch, so callers do not each need their own AJV validation. Related: #77.
eleith added the enhancement label 2026-09-26 12:41:41 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: eleith/luzzle#85