{"record":{"id":"c354f5913b56a4b4","repo":"serverless/serverless","slug":"missing-http-api-method","errorCode":"MISSING_HTTP_API_METHOD","errorMessage":"Missing \"method\" property in function ${functionName} for httpApi event in serverless.yml","messagePattern":"Missing \"method\" property in function (.+?) for httpApi event in serverless\\.yml","errorType":"exception","errorClass":"ServerlessError","httpStatus":null,"severity":"error","filePath":"packages/serverless/lib/plugins/aws/package/compile/events/http-api.js","lineNumber":618,"sourceCode":"              path = '*'\n            } else {\n              ;[, method, path] = methodPath.match(methodPathPattern)\n            }\n          }\n          path = String(path)\n          let routeKey\n          if (path === '*') {\n            if (method && method !== '*') {\n              throw new ServerlessError(\n                `Invalid \"path\" property in function ${functionName} for httpApi event in serverless.yml`,\n                'INVALID_HTTP_API_PATH',\n              )\n            }\n            routeKey = '*'\n            event.resolvedMethod = 'ANY'\n          } else {\n            if (!method) {\n              throw new ServerlessError(\n                `Missing \"method\" property in function ${functionName} for httpApi event in serverless.yml`,\n                'MISSING_HTTP_API_METHOD',\n              )\n            }\n            method = String(method).toUpperCase()\n            if (method === '*') {\n              method = 'ANY'\n            } else if (!allowedMethods.has(method)) {\n              throw new ServerlessError(\n                `Invalid \"method\" property in function ${functionName} for httpApi event in serverless.yml`,\n                'INVALID_HTTP_API_METHOD',\n              )\n            }\n            event.resolvedMethod = method\n            event.resolvedPath = path\n            routeKey = `${method} ${path}`\n\n            if (routes.has(routeKey)) {","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/serverless/serverless/blob/b9d7ea51c8cce57cff1207964b9b71123673081f/packages/serverless/lib/plugins/aws/package/compile/events/http-api.js#L600-L636","documentation":"Thrown when an httpApi event has a non-wildcard path but no method. Every non-'*' route needs an HTTP method to form the routeKey ('METHOD path'). Without a method the route cannot be registered with API Gateway. The wildcard '*' path is the only one that does not require a method.","triggerScenarios":"An httpApi event object { path: '/users' } with no method, or a string shorthand that fails to match methodPathPattern (so method is undefined) and whose path is not '*'. The `if (!method)` branch fires.","commonSituations":"Omitting method in object form assuming a default. Malformed string shorthand that does not parse as 'METHOD /path'. Resolver/variable producing an empty method.","solutions":["Add method: GET (or POST/PUT/PATCH/DELETE/HEAD/OPTIONS/ANY) to the event.","For string shorthand, use the 'METHOD /path' form exactly (e.g. 'GET /users').","For a catch-all use path: '*' which needs no method."],"exampleFix":"# before\nfunctions:\n  api:\n    events:\n      - httpApi:\n          path: /users\n# after\nfunctions:\n  api:\n    events:\n      - httpApi:\n          method: GET\n          path: /users\n      # or shorthand\n      - httpApi: 'GET /users'","handlingStrategy":"validation","validationCode":"const ALLOWED = ['ANY','GET','POST','PUT','PATCH','OPTIONS','HEAD','DELETE']\ncfg.functions && Object.entries(cfg.functions).forEach(([fn,f]) => (f.events||[]).forEach(e => {\n  if (e.httpApi && typeof e.httpApi === 'object' && e.httpApi.path !== '*' && !e.httpApi.method) {\n    throw new Error(`MISSING_HTTP_API_METHOD: fn ${fn} path ${e.httpApi.path} needs a method`)\n  }\n}))","typeGuard":"const hasMethodForConcretePath = (httpApi) =>\n  httpApi?.path === '*' ||\n  Boolean(httpApi?.method)","tryCatchPattern":null,"preventionTips":["Prefer the 'METHOD /path' string shorthand; it forces both parts to be present.","Treat path '*' as the only method-less route.","Add a CI YAML lint rule requiring method for every non-wildcard httpApi event."],"tags":["http-api","api-gateway","routing","config-validation"],"backgroundTag":null,"analyzedSha":"b9d7ea51c8cce57cff1207964b9b71123673081f","analyzedAt":"2026-08-13T04:14:40.386Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}