sickn33/agentic-awesome-skills · error · Error
User not found
Error message
User not found
What it means
Illustrative domain error in the processOrder BEFORE snippet: the order exists but fetchUser(order.userId) returned null/undefined, so the guard throws 'User not found'. It is the second level of the nested-try pyramid the skill wants to flatten.
Source
Thrown at skills/fp-async/SKILL.md:144
)
```
---
## 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?
await refundPayment(payment.id)
throw e
}
} catch (e) {View on GitHub (pinned to 58d857988f)
Solutions
- Query the users table for order.userId to confirm the reference is dangling
- Fix the data: restore the user, reassign the order, or add FK constraints to prevent orphans
- Refactor with TE.fromNullable to surface 'User not found' as a Left value in a flat pipeline
- Guard upstream: block order creation when the owning user is missing
Example fix
// before
const user = await fetchUser(order.userId)
if (!user) throw new Error('User not found')
// after
pipe(
fetchOrderTask(orderId),
TE.chain(order => fetchUserTask(order.userId)),
TE.chain(user => user == null
? TE.left(new Error('User not found'))
: TE.right(user))
) Defensive patterns
Strategy: validation
Validate before calling
const user = await fetchUser(order.userId)
if (user == null) return { kind: 'UserNotFound', userId: order.userId } Type guard
const isUser = (u: unknown): u is User => typeof u === 'object' && u !== null && 'id' in u && typeof (u as User).id === 'string'
Try / catch
catch (e) {
if (e instanceof Error && e.message === 'User not found') { /* show account-missing UI */ }
else throw e
} Prevention
- Enforce foreign keys so orders cannot reference missing users
- Treat a dangling userId as a data-integrity incident, not a user error
- Model each not-found as a tagged Left in the pipeline
When it happens
Trigger: Order rows referencing a userId with no matching user record (deleted user, orphaned foreign key, wrong-environment database).
Common situations: Data migrated without foreign-key enforcement; users soft-deleted but orders retained; cross-environment data drift where orders exist in staging but users do not.
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/1fe9ba90520b9ebf.
Report an issue: GitHub.