Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot have multiple functions targeting the same path with different methods #1909

Closed
brendanmckenzie opened this issue Aug 20, 2016 · 3 comments

Comments

@brendanmckenzie
Copy link

Serverless Framework Version:

1.0.0-beta.2

Operating System:

OSX 10.11.6

Expected Behavior:

Have the following configuration, one method GET user/profile another POST user/profile and receive an error on deployment.

functions:
  getProfile:
    handler: handler.getProfile
    events:
      - http:
          path: user/profile
          method: get
  updateProfile:
    handler: handler.updateProfile
    events:
      - http:
          path: user/profile
          method: post
Actual Behavior:
$ sls deploy
Serverless: Zipping service...
Serverless: Removing old service versions...
Serverless: Uploading .zip file to S3...
Serverless: Updating Stack...
Serverless: Checking stack update progress...
.. 
  Serverless Error ---------------------------------------

     An error occurred while provisioning your cloudformation:
     The following resource(s) failed to create: [ResourceApigEventGetprofileUserProfile].
@brendanmckenzie
Copy link
Author

This also resolved itself by re-creating the stack. #1908

@maludwig
Copy link

I have this error too. When I run "serverless remove", then "serverless deploy -v" though, it didn't resolve the issue. This is a problem since I have a normal API that follows the CRUD standard format (like django-rest-framework, or AngularJS Resource. I want to have URLs like:

POST    http://blahblah/task/            # Creates a new task
GET     http://blahblah/task/            # Gets all tasks
GET     http://blahblah/task/{taskId}    # Gets a specific task
PUT     http://blahblah/task/{taskId}    # Updates a specific task
DELETE  http://blahblah/task/{taskId}    # Deletes a specific task

I'm fine with doing exotic things to achieve this, I just want this URL format.

Here is the error I get:

Serverless: Deployment failed!

  Serverless Error ---------------------------------------

     An error occurred while provisioning your stack: ApiGatewayResourceTasksParenttaskidVar
     - A sibling ({taskId}) of this resource already has
     a variable path part -- only one is allowed.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues

  Your Environment Information -----------------------------
     OS:                 win32
     Node Version:       7.0.0
     Serverless Version: 1.7.0

@maludwig
Copy link

Wait no! Cancel this! It's just a bit of a poorly phrased error! Future people! Here was my problem:

http://forum.serverless.com/t/deployment-error-a-sibling-did-of-this-resource-already-has-a-variable-path-part-only-one-is-allowed/795

So essentially, I had two functions as down below, with two paths like this:

          path: tasks/{taskId}
          path: tasks/{taskToUpdate}

And both paths needed the same key, so I should have used {taskId} both times!

The only request I have for a developer seeing this is maybe to give a better error message than the one AWS gives.

functions:

  updateTask:
    handler: lib/endpoints.createTask
    events:
      - http:
          path: tasks/{taskToUpdate}
          method: put
          cors: true

  deleteTask:
    handler: lib/endpoints.deleteTask
    events:
      - http:
          path: tasks/{taskId}
          method: delete
          cors: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants