sickn33/agentic-awesome-skills · error · Error
Order not found
Error message
Order not found
What it means
Illustrative domain error from the processOrder BEFORE example: fetchOrder returned a falsy order (null/undefined), and the guard throws 'Order not found'. It demonstrates how deeply nested try/catch pyramids form when each step validates its own result.
Source
Thrown at skills/fp-async/SKILL.md:140
// From a condition
const mustBePositive = TE.fromPredicate(
(n: number) => n > 0,
(n) => new Error(`Expected positive, got ${n}`)
)
```
---
## 2. Chaining Async Operations
### The Problem: Callback Hell / Nested Awaits
```typescript
// BEFORE: Deeply nested, hard to follow
async function processOrder(orderId: string) {
try {
const order = await fetchOrder(orderId)
if (!order) throw new Error('Order not found')
try {
const user = await fetchUser(order.userId)
if (!user) throw new Error('User not found')
try {
const inventory = await checkInventory(order.items)
if (!inventory.available) throw new Error('Out of stock')
try {
const payment = await chargePayment(user, order.total)
if (!payment.success) throw new Error('Payment failed')
try {
const shipment = await createShipment(order, user)
return { order, shipment, payment }
} catch (e) {
// Refund payment? Log? What's the state now?View on GitHub (pinned to 58d857988f)
Solutions
- Verify the orderId exists before calling processOrder (preflight lookup or validation)
- Check whether fetchOrder should distinguish 'missing' (null) from 'fetch failed' (throw)
- Refactor to the skill's AFTER pipeline using TE.fromNullable / TE.fromOption so a missing order becomes a typed Left
- Return a discriminated error (e.g. { kind: 'OrderNotFound' }) so callers can branch cleanly
Example fix
// before
const order = await fetchOrder(orderId)
if (!order) throw new Error('Order not found')
// after
pipe(
TE.tryCatch(() => fetchOrder(orderId), E.toError),
TE.chain(order => order == null
? TE.left(new Error('Order not found'))
: TE.right(order)),
TE.chain(order => fetchUserTask(order.userId)),
TE.chain(user => chargePaymentTask(user, order.total))
) Defensive patterns
Strategy: validation
Validate before calling
if (!orderId || typeof orderId !== 'string') throw new TypeError('orderId required')
const exists = await orderExists(orderId)
if (!exists) return { kind: 'OrderNotFound', orderId } Type guard
const isOrder = (o: unknown): o is Order => typeof o === 'object' && o !== null && 'userId' in o && 'items' in o && 'total' in o
Try / catch
try {
const order = await fetchOrder(orderId)
if (!order) return { kind: 'OrderNotFound', orderId }
} catch (e) {
// fetch itself failed — distinct from a missing order
throw e
} Prevention
- Separate 'missing' from 'failed' in fetch functions
- Validate IDs before dispatch
- Return typed result objects instead of throwing for expected absences
When it happens
Trigger: processOrder called with an unknown, deleted, or mis-typed orderId; fetchOrder returning null instead of throwing; a race where the order was removed between lookup and processing.
Common situations: Stale IDs from client caches or old links; test fixtures referencing seeded data that was wiped; soft-deleted orders still referenced by other tables.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
AI-assisted analysis of sickn33/agentic-awesome-skills@58d857988f (2026-08-26).
Data as JSON: /api/errors/e4c66f12813b6d70.
Report an issue: GitHub.