Skip to content

Conversation

@kearen001
Copy link

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:

  • Change PUT route to /secret/{namespace}/{name} for REST consistency
  • Return correct HTTP status codes:
    • 201 Created for POST
    • 404 Not Found when secret does not exist
    • 409 Conflict when secret already exists
  • Add klog logging for error cases
  • Default to NamespaceAll when namespace is empty in GET
    Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

  • This change aligns Secret API routes with Kubernetes API conventions
  • Tested locally with GET/POST/PUT/DELETE requests
    Does this PR introduce a user-facing change?:
Secret API routes and error handling improved:
- PUT now requires `/secret/{namespace}/{name}`
- Proper status codes returned (201/404/409)
- Logs added for better debugging
- GET without namespace returns all namespaces
```release-note

@kubeedge-bot kubeedge-bot added kind/bug Categorizes issue or PR as related to a bug. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Sep 29, 2025
@kubeedge-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign vincentgoat after the PR has been reviewed.
You can assign the PR to them by writing /assign @vincentgoat in a comment when ready.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gemini-code-assist
Copy link

Summary of Changes

Hello @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

  • API Route Consistency: The PUT route for Secret API has been updated to /secret/{namespace}/{name} to align with RESTful conventions, requiring both namespace and name for updates.
  • Improved Error Handling and Status Codes: The API now returns more precise HTTP status codes: 201 Created for successful POST requests, 404 Not Found when a secret does not exist (for GET, PUT, DELETE), and 409 Conflict when attempting to create a secret that already exists.
  • Enhanced Logging: Added klog logging for various error cases across GET, POST, PUT, and DELETE operations, improving debuggability and operational visibility.
  • Default Namespace for GET Requests: GET requests for secrets will now default to NamespaceAll if no specific namespace is provided, allowing for easier retrieval of secrets across all namespaces.
  • Documentation Update: The README.md file has been updated to include a 'Notice' section regarding the --apiserver-skip-tls-verify option for self-signed certificates.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

yeyetianbing and others added 2 commits September 29, 2025 15:54
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]>
@kubeedge-bot kubeedge-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 29, 2025
@kearen001 kearen001 force-pushed the fix/secret-api-routes branch from babedb4 to 352d567 Compare September 29, 2025 07:54
Copy link

@gemini-code-assist gemini-code-assist bot left a 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")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
namespace := request.PathParameter("namespace")
namespace := request.PathParameter("namespace")
data.Namespace = namespace

@kubeedge-bot kubeedge-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 9, 2025
@kubeedge-bot
Copy link
Collaborator

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants