fix: While name in query return all trees#4484
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| serializer = TreeSerializer(nodes, many=True) | ||
| return [d for d in serializer.data if d.get('id') == d.get('workspace_id')] # 这是可序列化的字典 | ||
|
|
||
| return [d for d in serializer.data if d.get('id') == d.get('workspace_id')] if name is None else serializer.data # 这是可序列化的字典 |
There was a problem hiding this comment.
There are two main improvements recommended:
-
Null Check: Add a null check before the data processing code. This ensures that the function can handle cases where
namemight be None gracefully.
-
return [d for d in serializer.data if d.get('id') == d.get('workspace_id')]
-
if not name: -
return [d for d in serializer.data if d.get('id') == d.get('workspace_id')] -
...
- Return All Data When Name Is Not Provided: Ensure that when
nameis provided (i.e., non-NaN), it returns all serializable objects from the serializer without filtering based on the workspace ID.
This changes will make the function more robust and flexible, handling both regular use cases and edge cases like missing or unknown names.
fix: While name in query return all trees