{"record":{"id":"ea955dfa370dd283","repo":"hcengineering/platform","slug":"not-found-ea955d","errorCode":null,"errorMessage":"Not found","messagePattern":"Not found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"services/mail/pod-mail-worker/src/index.ts","lineNumber":76,"sourceCode":"      limit: config.mailSizeLimit\n    })\n  )\n\n  const catchError = (fn: RequestHandler) => (req: Request, res: Response, next: NextFunction) => {\n    void (async () => {\n      try {\n        await fn(req, res, ctx)\n      } catch (error: any) {\n        ctx.error('Failed to handle request', { method: req.method, path: req.path, error })\n        next(error)\n      }\n    })()\n  }\n\n  app.post('/mta-hook', catchError(handleMtaHook))\n\n  app.use((_req, res, _next) => {\n    res.status(404).send({ message: 'Not found' })\n  })\n\n  app.use((err: any, req: Request, res: any, _next: any) => {\n    ctx.error(err)\n    if (req.path === '/mta-hook') {\n      // Any error in the mta-hook should not prevent the mail server from handling emails\n      // At least the PayloadTooLargeError falls here before reacing our code\n      res.status(200).send({ action: 'accept' })\n      return\n    }\n    res.status(500).send({ message: err.message })\n  })\n\n  const server = app.listen(config.port, () => {\n    ctx.info('server started', {\n      ...config,\n      secret: config.secret !== undefined ? '(stripped)' : undefined,\n      hookToken: config.hookToken !== undefined ? '(stripped)' : undefined,","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/mail/pod-mail-worker/src/index.ts#L58-L94","documentation":"The pod-mail-worker Express app has a catch-all 404 handler that responds { message: 'Not found' } for any request not matched by an earlier route. Only /mta-hook (and any earlier middleware) is defined, so hitting any other path or verb yields this JSON 404. It signals the URL/method does not exist on this worker.","triggerScenarios":"Any request to the mail worker on a path other than POST /mta-hook — e.g. GET /, /healthz, /send, or POST to a misspelled path like /mta-hook/ with a trailing segment not registered.","commonSituations":"Health-check probes pointed at a path that does not exist; confusing pod-mail (which exposes send-mail endpoints) with pod-mail-worker (which only exposes /mta-hook); typos in internal service URLs; calling with the wrong HTTP verb on /mta-hook.","solutions":["Use POST /mta-hook for the mail-transfer-agent callback; that is the only route this worker exposes.","If you intended to send mail, call the pod-mail service instead of pod-mail-worker.","Fix the health-check/probe URL to an existing path or add an explicit /healthz route if needed.","Check for typos or an extra path prefix (e.g. double slashes) in the configured service URL."],"exampleFix":"// before\nawait fetch(`${workerUrl}/send-mail`, ...) // worker has no such route -> 404 Not found\n// after\nawait fetch(`${workerUrl}/mta-hook`, { method: 'POST', ... })","handlingStrategy":"validation","validationCode":"const WORKER_ROUTES = new Set(['/mta-hook'])\nfunction assertWorkerUrl(url: string, method = 'POST'): void {\n  const p = new URL(url).pathname.replace(/\\/$/, '')\n  if (!WORKER_ROUTES.has(p)) throw new Error(`${method} ${p} does not exist on pod-mail-worker (only /mta-hook)`)\n}","typeGuard":"function isMtaHookPath(pathname: string): boolean {\n  return pathname.replace(/\\/$/, '') === '/mta-hook'\n}","tryCatchPattern":"const res = await fetch(url, opts)\nif (res.status === 404) {\n  const body = await res.json().catch(() => null)\n  throw new Error(`wrong service/path: ${body?.message ?? 'not found'} — pod-mail-worker only exposes POST /mta-hook`)\n}","preventionTips":["Only send mail via the pod-mail service, not pod-mail-worker.","Register health probes against an existing path or add a /healthz route.","Double-check service URLs for typos and trailing path segments.","Match the HTTP verb: /mta-hook expects POST."],"tags":["http-404","express","routing","not-found"],"backgroundTag":"http-404-route-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}