Menu

Count what you can predict, retry what you can't
πŸ“°

Count what you can predict, retry what you can't

DEV Community: backendΒ·Hideki MoriΒ·19 days ago
#rQAErirN
#devtobackend#devto#dev#schema#unions
Long article (1760 words) β€” no AI summary yet.
Reading 0:00
15s threshold

A schema bug, a retry that couldn't help, and a small design rule I'm keeping.

The error

One day a StructFlow job β€” the structured-extraction service on my document-processing API β€” failed with an error I had never seen:

Schemas contains too many parameters with union types (27 parameters with type arrays or anyOf). This causes exponential compilation cost. Reduce the number of nullable or union-typed parameters (limit: 16 parameters with unions).

Enter fullscreen mode

Exit fullscreen mode

My first guess was length β€” the schema must be too big. Wrong. The input wasn't unusually long. More to the point, I had never written this schema at all: on this API, the output schema is derived from each user's example_output β€” a JSON example of the shape they want. That detail matters. A fixed internal schema either fits under a limit forever or fails on day one; my services built that way had run quietly for months.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.