-
Notifications
You must be signed in to change notification settings - Fork 42
fix: improve Secret API routes and error handling #100
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
base: main
Are you sure you want to change the base?
Conversation
|
[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.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary of ChangesHello @kearen001, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refines the Secret API by enhancing its consistency, error handling, and user-friendliness. The changes ensure that API routes adhere more closely to REST principles, provide clearer feedback through appropriate HTTP status codes, and improve debuggability with added logging. Additionally, it streamlines the retrieval of secrets by defaulting to all namespaces when none is specified, making the API more robust and intuitive for developers. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Signed-off-by: kearen001 <[email protected]>
…o /secret/{namespace}/{name} for consistency- Return correct HTTP codes: 201 for create, 404/409 for not found/conflict- Add klog for better debugging
Signed-off-by: kearen001 <[email protected]>
babedb4 to
352d567
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.
Code Review
This pull request significantly improves the Secret API handlers by aligning with REST principles, enhancing error handling with correct HTTP status codes, and adding valuable logging. The changes make the API more robust and easier to debug.
However, there is a critical issue. The API for updating a secret has changed from PUT /secret/{namespace} to PUT /secret/{namespace}/{name}, but the frontend code in modules/web/src/api/secret.ts has not been updated to use the new route. This will break the secret update functionality in the UI and must be addressed.
I have also added one review comment with a suggestion to make the handleCreateSecret function more robust by enforcing the namespace from the URL path, consistent with the approach in handleUpdateSecret.
Please address the frontend API call and consider the suggestion for the create handler.
| return | ||
| } | ||
|
|
||
| namespace := request.PathParameter("namespace") |
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 robustness, it's good practice to enforce that the secret's namespace matches the namespace from the URL path, similar to how it's done in handleUpdateSecret. If a client sends a request body with a different namespace, the Kubernetes API server will reject it. Explicitly setting the namespace from the path parameter makes the API behavior clearer and more predictable.
| namespace := request.PathParameter("namespace") | |
| namespace := request.PathParameter("namespace") | |
| data.Namespace = namespace |
|
@kearen001: PR needs rebase. Instructions 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/test-infra repository. |
What type of PR is this?
/kind bug
/kind api-change
/kind cleanup
What this PR does / why we need it:
This PR improves the Secret API handler to make it more consistent and user-friendly:
/secret/{namespace}/{name}for REST consistency201 Createdfor POST404 Not Foundwhen secret does not exist409 Conflictwhen secret already existskloglogging for error casesNamespaceAllwhen namespace is empty in GETWhich issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: