-
Notifications
You must be signed in to change notification settings - Fork 18
Add endpoints for file object and info key editing #893
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
Conversation
FYI @kofalt, @dpuccetti, @ryansanford @dpuccetti a review of the syntax and that it will work for frontend clients is all I'll need from you. |
@gsfr, @lmperry Is this intention still that editing a file's attributes via these routes will not trigger jobs? That was the intention with the classification change. Let me know if opinions have shifted. An idea: it could be an opt-in two step process. If the client sends a query param like |
After discussion with @gsfr offline, changes should spawn jobs and it will be the default behavior. Any change to make it optional can come at a later date if necessary. |
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.
Two quick suggestions, then LGTM!
update = {} | ||
set_payload = payload.get('set') | ||
delete_payload = payload.get('delete') | ||
replace_payload = payload.get('replace') |
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.
Suggestion: reject the update if both replace and (delete or set) is not None.
I get that the json schema prevents the handler from sending over a payload that is invalid in that manner, but it make sense (to me at least) that the persistent layer should only allow valid mutations.
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.
Don't we consider the schemas to be an integral part of the persistence layer? If not, wouldn't we need to add input validation all over the code? Maybe this is different somehow, and I'm not seeing it.
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.
We had a conversation about this very thing :) Our conclusion is that in general, you don't need to re-implement schemas, but the persistence layer isn't an HTTP layer and at minimum shouldn't expose undefined behavior. This is the rare exception (combining set with replace with delete).
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.
Kofalt and I briefly discussed this. Since it's not business or schema logic, I added an extra check for other parts of the code that may call this function. I'd rather have a descriptive 500 if someone misused it than a mongo error about key-wise vs full key sets. I do agree that business logic/schema validation belongs at the handler levels.
|
||
|
||
|
||
|
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.
Excess ending whitespace ¯\(ツ)/¯
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 is an important step forward for us. Great to have it.
update = {} | ||
set_payload = payload.get('set') | ||
delete_payload = payload.get('delete') | ||
replace_payload = payload.get('replace') |
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.
Don't we consider the schemas to be an integral part of the persistence layer? If not, wouldn't we need to add input validation all over the code? Maybe this is different somehow, and I'm not seeing it.
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.
Changes LGTM!
New endpoints:
Note: using either of these endpoints does not trigger jobs based on gear rules as per previous discussionThis endpoint should spawn jobsPUT /api/container/container_id/files/file_name
Endpoint that allows editing of file object.
Allowable fields:
* Must be an array, replaces existing array
Example Request
POST /api/container/container_id/files/file_name/info
Format of request:
key
:value
(values may be scalars or complex objects). All keys are added to theinfo
key if they do not exist, or are replaced by thevalue
if they do existOR
info
key for the file. It can be an empty map.Example Requests
Breaking Changes
Review Checklist