-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add optional required
configuration to parameters
#134
Conversation
Thanks for implementing this @cdubz. You may want to update the docs for this as well. |
Documentation added. We should add a test as well. |
Hi @cdubz and @geetchoubey, Thank you so much for raising this PR. I haven't been able to reproduce the issue you're having (for me, endpoints don't error when a cache key parameter is missing), but I think I understand what's going on. I'm not convinced that adding an extra "required" boolean parameter alongside cache key parameter names is the solution, because there's already an out-of-the-box serverless feature to toggle whether parameters are required. A sample from this yaml: functions:
hello:
events:
# REST API endpoint (API Gateway v1)
- http:
path: users/create
method: get
request:
parameters:
paths:
paramName: true # mark path parameter as required
headers:
headerName: true # mark header as required
querystrings:
paramName: true # mark query string I had a quick play around since I found the settings above, and it looks like they're applied after this plugin does its thing. So, if this plugin defaults to "false", then they can be marked as required by code like the above. |
Any updates on this 👀 |
I am intending to test @DianaIonita's recommendation but just haven't had the time yet 😭 In our current config we have some optional parameters that are just not listed in the Here's an example real endpoint we have configured: showDetail:
handler: handler.router
timeout: 15
events:
- http:
path: shows/{showUuid}
method: get
caching:
enabled: true
cacheKeyParameters:
- name: request.header.x-canada-filter
- name: request.path.showUuid
private: true In this case the request:
parameters:
headers:
x-canada-filter: false |
@DianaIonita currently there already is a I believe the change you're proposing is a separate breaking change to the current configuration spec. My 2 cents, merge this as is. It will remedy the breaking change that occurred from #132. Therefore all the people that have been using this package prior to Then the configuration change @DianaIonita is proposing can perhaps come in a correctly semver'd |
Hi everyone, This is my suggestion:
This way, we avoid the confusion of having two config options that do the same thing. It also doesn't need the developer to remember any special behaviours of this caching plugin. |
@DianaIonita I created #138 to implement your suggestions. |
Thanks everyone. I just created release 1.10.4 which includes @josh-feather's change of making cache key parameter not required by default. |
Changes made in #132 made all
cacheKeyParameters
values required by default but previously this was not the case. This breaks functions that rely on cache key parameters based on optional headers/query strings/etc.This is an implementation of @geetchoubey's recommendation from #132 (comment).
This change allows a config like this:
And the
required
value defaults tofalse
so backwards compatibility is maintained with versions before this bug was introduced in1.10.3
.Fixes #133