Skip to content

Bug fix: GET operation does not include namespace#185

Merged
fuweid merged 1 commit into
mainfrom
bug_fix_url
Jul 10, 2025
Merged

Bug fix: GET operation does not include namespace#185
fuweid merged 1 commit into
mainfrom
bug_fix_url

Conversation

@vittoriasalim
Copy link
Copy Markdown
Contributor

Fix: 404 Error When Namespace Is Specified in GET Request

Previously, a GET request for a namespaced resource returned a 404 error, even when the resource name was valid:

{
  "url": "https://10.0.0.1:443/api/v1/pods/node10job1pod1k-1?resourceVersion=0&timeout=1m0s",
  "timestamp": "2025-07-09T04:33:54.232768244Z",
  "duration": 0.002615457,
  "type": "http",
  "code": 404,
  "message": ""
}

This occurred because the namespace was not properly included in the request path. According to the Kubernetes API specification, the correct format for retrieving a resource by name within a namespace should be:

/api/v1/namespaces/{namespace}/pods/{name}

Expected Format

Root Cause

The namespace segment was missing in the GET request path construction logic, which led to incorrect targeting and ultimately a 404.

Solution

This PR corrects the GET request path by appending the namespace when specified. After applying this fix, the request behaves as expected:

Fixed Result

This change aligns the implementation with Kubernetes API standards.

Thanks to @xinWeiWei24 for helping me navigating this issue

@vittoriasalim vittoriasalim requested a review from fuweid July 9, 2025 23:11
Copy link
Copy Markdown
Collaborator

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM!

@fuweid fuweid merged commit 36c1324 into main Jul 10, 2025
4 checks passed
@vittoriasalim vittoriasalim deleted the bug_fix_url branch August 6, 2025 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants