Skip to content

Default empty namespace to "default" in API client - #858

Open
lirenjie95 wants to merge 1 commit into
eclipse-symphony:mainfrom
lirenjie95:fix/apiclient-default-namespace
Open

Default empty namespace to "default" in API client#858
lirenjie95 wants to merge 1 commit into
eclipse-symphony:mainfrom
lirenjie95:fix/apiclient-default-namespace

Conversation

@lirenjie95

@lirenjie95 lirenjie95 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #466

Problem

The API client (api/pkg/apis/v1alpha1/utils/apiclient.go) appends namespace to the query string as-is. When a caller passes an empty namespace, the request goes out with ?namespace= and the server looks objects up under an empty namespace instead of the default one.

Fix

  • Add a withDefaultNamespace helper that returns "default" for an empty namespace.
  • Use it at every url.QueryEscape(namespace) call site in apiclient.go (30 occurrences).

This matches the convention already used elsewhere in the repo (jobs-manager, stage-manager, target-manager, model/objectmeta.go, etc.), where an empty namespace falls back to "default".

Scope

Only point 1 of the issue is covered by this PR. Point 2 (auditing remaining symphony-api.go callers) and point 3 (filling in missing API client methods) are handled separately.

Test

Added apiclient_test.go: an httptest server records the incoming query — GetInstances with an empty namespace asserts namespace=default, and an explicit namespace passes through unchanged.

@lirenjie95
lirenjie95 requested a review from Haishi2016 as a code owner August 10, 2026 10:21
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.

no check for the namespace is empty in apiclient.go

1 participant