{"record":{"id":"968ac01148ad5aef","repo":"hcengineering/platform","slug":"not-found-968ac0","errorCode":null,"errorMessage":"Not found","messagePattern":"Not found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"services/gmail/pod-gmail/src/server.ts","lineNumber":48,"sourceCode":"  })()\n}\n\nexport function createServer (endpoints: Endpoint[]): Express {\n  const app = express()\n\n  app.use(cors())\n  app.use(express.json())\n\n  endpoints.forEach((endpoint) => {\n    if (endpoint.type === 'get') {\n      app.get(endpoint.endpoint, catchError(endpoint.handler))\n    } else if (endpoint.type === 'post') {\n      app.post(endpoint.endpoint, catchError(endpoint.handler))\n    }\n  })\n\n  app.use((_req, res, _next) => {\n    res.status(404).send({ message: 'Not found' })\n  })\n\n  app.use((err: any, _req: any, res: any, _next: any) => {\n    if (err instanceof ApiError) {\n      res.status(400).send({ code: err.code, message: err.message })\n      return\n    }\n\n    res.status(500).send({ message: err.message })\n  })\n\n  return app\n}\n\nexport function listen (e: Express, port: number, host?: string): Server {\n  const cb = (): void => {\n    console.log(`Gmail service has been started at ${host ?? '*'}:${port}`)\n  }","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/gmail/pod-gmail/src/server.ts#L30-L66","documentation":"The Express 404 catch-all middleware in createServer responds { message: 'Not found' } when no route matched the request. It means the request path or HTTP method does not correspond to any registered endpoint in the pod.","triggerScenarios":"Hitting a wrong path (typo, wrong port/service), using GET on a POST-only endpoint like /start-sync, or calling a route that was never registered in this pod's endpoints array.","commonSituations":"Proxy/routing config points to the wrong pod or port; API path renamed after a version upgrade; trailing-slash or case mismatches; client calls an endpoint implemented in a different service.","solutions":["Compare the request URL/method against the endpoints registered in main.ts and server.ts","Check gateway/proxy routing rules to confirm traffic reaches the correct pod and port","Fix path typos, trailing slashes, or HTTP method mismatches in the client","Verify you are running the expected service version that registers the route"],"exampleFix":"// before\nawait fetch(`${base}/start-sync`, { method: 'GET' })\n// after\nawait fetch(`${base}/start-sync`, { method: 'POST', headers })","handlingStrategy":"validation","validationCode":"const allowed = new Set(['/integration-state', '/start-sync'])\nconst u = new URL(fullUrl)\nif (!allowed.has(u.pathname.replace(/\\/$/, ''))) throw new Error(`unknown pod-gmail route: ${u.pathname}`)","typeGuard":"function isKnownEndpoint(path: string, method: string): boolean {\n  return method === 'POST' ? path === '/start-sync' : path === '/integration-state'\n}","tryCatchPattern":"try {\n  const res = await fetch(url, opts)\n  if (res.status === 404) {\n    const body = await res.json()\n    if (body.message === 'Not found') throw new Error(`Route ${opts.method} ${url} not registered — check path/method/service`)\n  }\n} catch (e) { /* fix routing or path */ }","preventionTips":["Keep a generated route list per pod and validate client calls against it","Fix the HTTP method (POST for /start-sync) and avoid trailing slashes","Check proxy/gateway route tables when moving services between ports/hosts"],"tags":["http-404","express","routing","rest-api"],"backgroundTag":"route-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}