-
Notifications
You must be signed in to change notification settings - Fork 8
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
allow list of states in flaw filter #469
Conversation
1b45735
to
f22cdbc
Compare
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.
LGTM, I'm for merging this and discussing the nitpick asynchronously.
type: array | ||
items: | ||
type: string | ||
description: Multiple values may be separated by commas. |
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.
Nitpick: The enum in openapi.yml seems kind of useful for knowing which values are valid. We are losing that usefulness here. I see that Flaw's cve_id
has the same drawback in openapi.yml, so this PR already has a precedent that it is OK. I'd just like to discuss (even after merging this) whether we want to somehow improve openapi.yml for fields that use CharInFilter
, and whether anyone would even care. @RedHatProductSecurity/osidb-devs thoughts?
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.
For cve_id
I think it is kinda different as it is not an enum and the field is pretty self explanatory, but losing an enum values might be problematic for anyone who would like to work with the API. I posted some possible solutions below, not tested them thoroughly or sure about them, just something to think about.
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.
Sorry for sticking my nose into this but I've noticed during the standup that this is about filters so I might give a quick opinion on this. 😄
type: string | ||
enum: | ||
- DONE | ||
- NEW | ||
- PRE_SECONDARY_ASSESSMENT | ||
- REJECTED | ||
- SECONDARY_ASSESSMENT | ||
- TRIAGE |
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.
I think this is not entirely correct as we lost information about possible values of the enum, this could be easily solved if you use a different filter for the workflow_state:
from django_filters.rest_framework import ChoiceFilter, BaseInFilter
class ChoiceInFilter(BaseInFilter, ChoiceFilter):
"""
Filter for choice csv
"""
pass
workflow_state = ChoiceInFilter(field_name="workflow_state")
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 this might not work correctly, there also exist MultipleChoiceFilter
, not sure how that works, just pointing out that enum values should be exposed in the schema
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.
I am also in favor of finding a way how to preserve the enumeration values listed in the OpeAPI
f22cdbc
to
99d16ee
Compare
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.
See my comment above. I forgot to request the change.
99d16ee
to
135d124
Compare
Makes sense, submitted the change suggested by @JakubFrejlach, thanks you all |
@costaconrado Actually I am not sure, but it might be necessary to explicitly list the choices via workflow_state_choices = [
(s.value, s.value) for s in Flaw.WorkflowState
] something like this probably |
@JakubFrejlach I believe I can use something like: let me test it |
135d124
to
1597d6c
Compare
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.
Much better 😺 thank you for addressing the feedback!
Signed-off-by: Conrado Costa <concosta@redhat.com>
1597d6c
to
11d60c5
Compare
This PR changes flaw API to allow filtering by a list of
workflow_state
.Closes OSIDB-2208.