DianaIonita / serverless-api-gateway-caching

A plugin for the Serverless framework which helps with configuring caching for API Gateway endpoints.
ISC License
136 stars 35 forks source link

[Bug]: Empty paths cause issues with caching settings. Properly handle empty paths. #94

Closed jspreddy closed 2 years ago

jspreddy commented 2 years ago

Summary:

When the path resolves to "", the stage level cache settings are auto propagated to this endpoint.

Config:

custom:
  apiGatewayCaching:
    enabled: true
    clusterSize: '0.5'
    ttlInSeconds: 600
    perKeyInvalidation:
      requireAuthorization: false

functions:
  blah:
    events:
      - http:
          path: ""
          method: get
      - http:
          path: "/{id}"
          method: get
          caching:
            enabled: true
            cacheKeyParameters:
              - name: request.path.id

On Deploy

i.e. Even though this endpoint "/" does not have caching enabled, since the plugin silently fails with undefined for the operation, the stage level cache settings are propagated to this specific endpoint.

Version Info

npm run sls info

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              12.14.1
     Framework Version:         1.71.3
     Plugin Version:            3.8.4
     SDK Version:               2.3.2
     Components Version:        2.34.9

package-lock.json

{
    "serverless-api-gateway-caching": {
      "version": "1.7.3",
      "resolved": "https://registry.npmjs.org/serverless-api-gateway-caching/-/serverless-api-gateway-caching-1.7.3.tgz",
      "integrity": "sha512-SqcuqAlAsOqbkHgwcyTh835TmkJfh/r9nbcjaC8gXXDZ6il3aZxtFgeX3fUGMaOl9hcC9SSJAkSO1ESL+oTGvQ==",
      "dev": true,
      "requires": {
        "lodash.get": "^4.4.2",
        "lodash.isempty": "^4.4.0"
      }
    },
}
DianaIonita commented 2 years ago

Hi @jspreddy,

Thanks for reporting this issue. It should now be fixed in the latest version of the plugin, 1.7.4