hcengineering/platform · warning

Not found

Error message

Not found

What it means

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.

Source

Thrown at services/gmail/pod-gmail/src/server.ts:48

  })()
}

export function createServer (endpoints: Endpoint[]): Express {
  const app = express()

  app.use(cors())
  app.use(express.json())

  endpoints.forEach((endpoint) => {
    if (endpoint.type === 'get') {
      app.get(endpoint.endpoint, catchError(endpoint.handler))
    } else if (endpoint.type === 'post') {
      app.post(endpoint.endpoint, catchError(endpoint.handler))
    }
  })

  app.use((_req, res, _next) => {
    res.status(404).send({ message: 'Not found' })
  })

  app.use((err: any, _req: any, res: any, _next: any) => {
    if (err instanceof ApiError) {
      res.status(400).send({ code: err.code, message: err.message })
      return
    }

    res.status(500).send({ message: err.message })
  })

  return app
}

export function listen (e: Express, port: number, host?: string): Server {
  const cb = (): void => {
    console.log(`Gmail service has been started at ${host ?? '*'}:${port}`)
  }

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Compare the request URL/method against the endpoints registered in main.ts and server.ts
  2. Check gateway/proxy routing rules to confirm traffic reaches the correct pod and port
  3. Fix path typos, trailing slashes, or HTTP method mismatches in the client
  4. Verify you are running the expected service version that registers the route

Example fix

// before
await fetch(`${base}/start-sync`, { method: 'GET' })
// after
await fetch(`${base}/start-sync`, { method: 'POST', headers })
Defensive patterns

Strategy: validation

Validate before calling

const allowed = new Set(['/integration-state', '/start-sync'])
const u = new URL(fullUrl)
if (!allowed.has(u.pathname.replace(/\/$/, ''))) throw new Error(`unknown pod-gmail route: ${u.pathname}`)

Type guard

function isKnownEndpoint(path: string, method: string): boolean {
  return method === 'POST' ? path === '/start-sync' : path === '/integration-state'
}

Try / catch

try {
  const res = await fetch(url, opts)
  if (res.status === 404) {
    const body = await res.json()
    if (body.message === 'Not found') throw new Error(`Route ${opts.method} ${url} not registered — check path/method/service`)
  }
} catch (e) { /* fix routing or path */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/968ac01148ad5aef. Report an issue: GitHub.