{"record":{"id":"8352e185671ad672","repo":"sickn33/agentic-awesome-skills","slug":"order-not-found-8352e1","errorCode":null,"errorMessage":"Order not found","messagePattern":"Order not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"skills/fp-pragmatic/SKILL.md","lineNumber":503,"sourceCode":"        ? E.right(obj.email)\n        : E.left('Valid email required')\n    ),\n    E.bind('age', ({ obj }) =>\n      typeof obj.age === 'number' && obj.age >= 0\n        ? E.right(obj.age)\n        : E.left('Valid age required')\n    ),\n    E.map(({ email, age }) => ({ email, age }))\n  )\n```\n\n### Promise Chain to TaskEither\n\n```typescript\n// Before\nasync function processOrder(orderId: string): Promise<Receipt> {\n  const order = await fetchOrder(orderId)\n  if (!order) throw new Error('Order not found')\n\n  const validated = await validateOrder(order)\n  if (!validated.success) throw new Error(validated.error)\n\n  const payment = await processPayment(validated.order)\n  if (!payment.success) throw new Error('Payment failed')\n\n  return generateReceipt(payment)\n}\n\n// After\nconst processOrder = (orderId: string): TE.TaskEither<string, Receipt> =>\n  pipe(\n    fetchOrderTE(orderId),\n    TE.flatMap(order =>\n      order ? TE.right(order) : TE.left('Order not found')\n    ),\n    TE.flatMap(validateOrderTE),","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/sickn33/agentic-awesome-skills/blob/58d857988fcfac6986206bca2b2fe223aa437e4b/skills/fp-pragmatic/SKILL.md#L485-L521","documentation":"This error comes from the imperative 'Before' example in the fp-pragmatic skill's Promise-to-TaskEither section. fetchOrder returned a falsy value (null/undefined), meaning no order with that id exists, and the code converts that into a thrown Error.","triggerScenarios":"Calling processOrder(orderId) where fetchOrder resolves to null or undefined — wrong id, deleted order, or a lookup against the wrong environment's database.","commonSituations":"Stale ids from emails or cached UIs; environment mismatch (id exists in staging but not production); deleted or archived records; race where the order is cancelled between listing and processing.","solutions":["Verify the order id exists via a GET before processing, or surface a typed 404 to the client","Check that you are querying the correct environment/database","Convert the pipeline to TE.TaskEither as the skill's 'After' shows, mapping a null fetch to TE.left('Order not found')"],"exampleFix":"// before\nconst order = await fetchOrder(orderId)\nif (!order) throw new Error('Order not found')\n\n// after\nconst getOrder = (id: string) =>\n  TE.tryCatch(() => fetchOrder(id), E.toError)\n// then chain a null-check returning TE.left('Order not found')","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isOrder = (x: unknown): x is Order =>\n  typeof x === 'object' && x !== null && 'id' in x && 'status' in x","tryCatchPattern":"try {\n  await processOrder(orderId)\n} catch (e) {\n  if (e instanceof Error && e.message === 'Order not found') {\n    // return 404 to caller\n  }\n  throw e\n}","preventionTips":["Verify order ids exist before dispatching processing jobs","Confirm the target environment/database before debugging missing orders"],"tags":["not-found","async","order-processing","fp-ts"],"backgroundTag":"resource-not-found","analyzedSha":"58d857988fcfac6986206bca2b2fe223aa437e4b","analyzedAt":"2026-08-26T11:55:59.350Z","schemaVersion":2},"datasetVersion":"2026-08-26T14:46:13.012Z"}