-
Notifications
You must be signed in to change notification settings - Fork 63
Validate sort order in admin.ResourceListRequest #606
Conversation
Signed-off-by: Iaroslav Ciupin <[email protected]>
Signed-off-by: Iaroslav Ciupin <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #606 +/- ##
==========================================
+ Coverage 58.68% 60.30% +1.61%
==========================================
Files 171 171
Lines 16484 13454 -3030
==========================================
- Hits 9674 8113 -1561
+ Misses 5958 4488 -1470
- Partials 852 853 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Signed-off-by: Iaroslav Ciupin <[email protected]>
235e18e
to
cbbe1ca
Compare
Signed-off-by: Iaroslav Ciupin <[email protected]>
return nil, err | ||
} | ||
|
||
sortParameters, err := common.NewSortParameters(&request, gormimpl.ExecutionColumns) |
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.
Because we join on multiple tables for the list request we should support sort columns from any of the supported tables
See https://docs.flyte.org/en/latest/concepts/admin.html#putting-it-all-together for how we document table_name.field as an option sort
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.
@katrogan from what I see from code and docs, we are joining with tables references in filters, not in sort_by.
I was able to successfully perform this query https://dogfood.cloud-staging.union.ai/api/v1/executions/flytesnacks/development?limit=5&filters=eq(workflow.name,ray_example.ray_example.ray_workflow)
But I got an error for
https://dogfood.cloud-staging.union.ai/api/v1/executions/flytesnacks/development?limit=5&sort_by.key=workflow.name&filters=eq(workflow.name,ray_example.ray_example.ray_workflow)
and
https://dogfood.cloud-staging.union.ai/api/v1/executions/flytesnacks/development?limit=5&sort_by.key=workflow.name
Error
{
"error": "cannot query with specified table attributes: missing FROM-clause entry for table \"workflow\"",
"code": 3,
"message": "cannot query with specified table attributes: missing FROM-clause entry for table \"workflow\""
}
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 for the verification @iaroslav-ciupin
do you mind filing a follow-up issue to ensure that we update JoinTableEntities to include other tables when they're included in the sort key as well?
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.
Actually, can you still ensure that we pass in the join table columns here as allowed columns?
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.
@katrogan I don't get, why? we currently don't support sorting by join table columns and return error containing database schema details which is not a good thing. Wouldn't it be better to return a clearer validation error ?
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.
ah I see - missed your second example, so even for the successful join call, e.g.
/api/v1/executions/flytesnacks/development?limit=5&filters=eq(workflow.name,ray_example.ray_example.ray_workflow)&sort_by.key=workflow.created_at&sort_by.direction=DESCENDING
we still fail to sort by so we're not removing functionality in this change
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.
@katrogan exactly, although we specify join table column in filter and we still can't sort by join table column
return nil, err | ||
} | ||
|
||
sortParameters, err := common.NewSortParameters(&request, gormimpl.ExecutionColumns) |
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.
Actually, can you still ensure that we pass in the join table columns here as allowed columns?
TL;DR
Validate sort order by checking it against supported columns. This PR only checks sort order in
admin.ResourceListRequest
, other requests will be added in separate PR. Also validation for filters will be added in separate PR.Type
Are all requirements met?
Complete description
How did you fix the bug, make the feature etc. Link to any design docs etc
Tracking Issue
Remove the 'fixes' keyword if there will be multiple PRs to fix the linked issue
fixes https://github.com/flyteorg/flyte/issues/
Follow-up issue
NA
OR
https://github.com/flyteorg/flyte/issues/