serverless / blog

serverless.com/blog – Posts from the Serverless community & core team. Contributions welcome!
https://serverless.com/blog/
185 stars 197 forks source link

Unable to create resource at path #629

Open jarakkal opened 6 years ago

jarakkal commented 6 years ago

https://github.com/serverless/blog/blob/master/posts/2018-05-07-how-create-rest-api-serverless-components.md

I am following the above post, getting an error when running 'components deploy'

BadRequestException: Errors found during import: Unable to create resource at path '/\leads': Resource's path part only allow a-zA-Z0-9._- and curly braces at the beginning and the end. Unable to create resource at path '/\leads\{id}': Resource's path part only allow a-zA-Z0-9._- and curly braces at the beginning and the end. at Object.extractError (C:\Users\jento\AppData\Roaming\npm\node_modules\serverless-components\registry\aws-apigateway\node_modules\aws-sdk\lib\protocol\json.js:48:27) at Request.extractError (C:\Users\jento\AppData\Roaming\npm\node_modules\serverless-components\registry\aws-apigateway\node_modules\aws-sdk\lib\protocol\rest_json.js:52:8) at Request.callListeners (C:\Users\jento\AppData\Roaming\npm\node_modules\serverless-components\registry\aws-apigateway\node_modules\aws-sdk\lib\sequential_executor.js:105:20) at Request.emit (C:\Users\jento\AppData\Roaming\npm\node_modules\serverless-components\registry\aws-apigateway\node_modules\aws-sdk\lib\sequential_executor.js:77:10) at Request.emit (C:\Users\jento\AppData\Roaming\npm\node_modules\serverless-components\registry\aws-apigateway\node_modules\aws-sdk\lib\request.js:683:14) at Request.transition (C:\Users\jento\AppData\Roaming\npm\node_modules\serverless-components\registry\aws-apigateway\node_modules\aws-sdk\lib\request.js:22:10) at AcceptorStateMachine.runTo (C:\Users\jento\AppData\Roaming\npm\node_modules\serverless-components\registry\aws-apigateway\node_modules\aws-sdk\lib\state_machine.js:14:12)

I tried removing {id}, but still get the same error.

Please help. My serverless.yml

....
type: rest-api
    inputs:
      gateway: aws-apigateway
      routes:
        /leads:
          post:
            function: ${createLead}
            cors: true
          get:
            function: ${listLeads}
            cors: true
          /{id}:
            get:
              function: ${getLead}
              cors: true
....
82949712 commented 6 years ago

same question

pmuens commented 5 years ago

Hey @jarakkal and @82949712

🤔 that's interesting. Never seen such an error before. Can you try to remove the / from /leads and try again.

Are both of you running Windows as an OS? My hunch is that there's something Windows-specific going on when the path definition is processed.

We're currently refactoring the codebase and will publish a new version of such soon.