-
Notifications
You must be signed in to change notification settings - Fork 375
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
fix: validate action of getSignedUrl() function #684
Conversation
Codecov Report
@@ Coverage Diff @@
## master #684 +/- ##
==========================================
+ Coverage 98.04% 98.04% +<.01%
==========================================
Files 9 9
Lines 921 922 +1
Branches 100 100
==========================================
+ Hits 903 904 +1
Misses 9 9
Partials 9 9
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the behavior of the old API, if I were to pass in an invalid action? This looks great, my only concern is it might be a breaking change:
- if the old logic would have failed with a more cryptic error, this seems reasonable as a non-breaking change.
- if prior to this we would have succeeded, this feels like a breaking change.
Assuming we would have previously been throwing an exception, I'm 👍 on this change.
src/file.ts
Outdated
@@ -2319,6 +2319,12 @@ class File extends ServiceObject<File> { | |||
*/ | |||
getSignedUrl(cfg: GetSignedUrlConfig, callback?: GetSignedUrlCallback): | |||
void|Promise<GetSignedUrlResponse> { | |||
const validAction = ['read', 'write', 'delete', 'resumable']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me, might be worth considering using an Enum
for TypeScript
, does this translate cleanly to the JavaScript API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's actually already this enum:
Line 2341 in 7b1ef2c
const method = ActionToHTTPMethod[cfg.action]; |
We could just validate that method
is something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done
Previously |
@AVaksman feels like a |
Fixes #671
add validation for
action
parameter.