{"record":{"id":"7cb7b0fce2536aa9","repo":"honojs/hono","slug":"unmet-condition","errorCode":null,"errorMessage":"Unmet condition","messagePattern":"Unmet condition","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/middleware/combine/index.ts","lineNumber":109,"sourceCode":" *   myCheckLocalNetwork(),\n *   every(\n *     bearerAuth({ token }),\n *     myRateLimit({ limit: 100 }),\n *   ),\n * ));\n * ```\n */\nexport const every = (...middleware: (MiddlewareHandler | Condition)[]): MiddlewareHandler => {\n  return async function every(c, next) {\n    const currentRouteIndex = c.req.routeIndex\n    await compose(\n      middleware.map((m) => [\n        [\n          async (c: Context, next: Next) => {\n            c.req.routeIndex = currentRouteIndex // should be unchanged in this context\n            const res = await m(c, next)\n            if (res === false) {\n              throw new Error('Unmet condition')\n            }\n            return res\n          },\n        ],\n      ])\n    )(c, next)\n  }\n}\n\n/**\n * Create a composed middleware that runs all middleware except when the condition is met.\n *\n * @param condition - A string or Condition function.\n * If there are multiple targets to match any of them, they can be passed as an array.\n * If a string is passed, it will be treated as a path pattern to match.\n * If a Condition function is passed, it will be evaluated against the request context.\n * @param middleware - A composed middleware\n *","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/honojs/hono/blob/e2740d5a1bd0b4254e517e3af8b60789284bc7bd/src/middleware/combine/index.ts#L91-L127","documentation":"This error is thrown by Hono's combine() middleware when a wrapped condition middleware returns exactly false, signaling its condition was not met. every() wraps each middleware so that a boolean false return is converted into an 'Unmet condition' Error; this lets you express allOf-style routing where all conditions must pass. It is a control-flow signal used with combine/every/some, not a bug indicator by itself.","triggerScenarios":"Using every(...) with a condition middleware (e.g. from hono/combine or custom predicates) that returns false for the current request; chaining conditionals where one middleware evaluates the request (path, header, query) and returns false to reject it; using some(...) incorrectly when you meant all conditions to be required.","commonSituations":"Custom guard middleware returning false (e.g. checking an API version header), combining basename/pathname matchers where one doesn't match, expecting false-returning middleware to just skip downstream handling instead of throwing.","solutions":["Make the condition middleware return true (or undefined/Response) when the condition passes so every() proceeds","If partial matches should pass, use some(...) instead of every(...) so any single true suffices","Ensure condition helpers return booleans, not 'false' strings or 0 which may behave unexpectedly","Wrap routes so condition-mismatched requests fall through to other handlers instead of erroring (order routes/middleware appropriately)"],"exampleFix":"// before\nconst middleware = every(\n  (c, next) => { return c.req.header('x-version') === '2' } // false → throws 'Unmet condition'\n)\n\n// after\nconst middleware = every(\n  (c, next) => {\n    if (c.req.header('x-version') !== '2') return c.text('Wrong version', 400)\n    return next()\n  }\n)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await app.request(req)\n} catch (err) {\n  if (err instanceof Error && err.message === 'Unmet condition') {\n    return new Response('Condition not met', { status: 400 })\n  }\n  throw err\n}","preventionTips":["Condition middleware should return true/undefined/Response, reserving false for intentional rejection","Choose every() vs some() deliberately: AND vs OR semantics","Keep condition predicates pure and unit-test them against sample requests","Return a Response from guards when you want a specific status instead of an error"],"tags":["combine","middleware","conditions","control-flow"],"backgroundTag":"middleware-condition-failed","analyzedSha":"e2740d5a1bd0b4254e517e3af8b60789284bc7bd","analyzedAt":"2026-08-28T10:18:08.750Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}