Fix: empty --namespace coerced to __default__ on all vector/record commands#88
Merged
Merged
Conversation
…perspective, this avoids an underlying issue in the current Go SDK
"__default__") namespace conversion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #85.
When a user passes
--namespace ""to any index vector or record command, the CLI ignores it and silently queries the__default__namespace instead, returning no results even though vectors exist in the default namespace.The root cause is in the Go SDK:
pc.Index()coercesNamespace: ""to"__default__"unconditionally (go-pinecone client.go:286). This means the literal string"__default__"is sent on the wire over gRPC.Sending
"__default__"requires an active server-side conversion to map it back to""(the canonical internal representation of the default namespace). That conversion only runs at API version ≥ 2025-04; at older API versions the server actively blocks it with a validation error. By contrast, sending""directly passes through unchanged on every server version — it is the proto3 zero value for a string field (omitted on the wire) and the server always treats an absent namespace as the default.Additionally, the Go SDK's assumption was incorrect:
"__default__"was introduced as a human-readable alias that clients can send, not the canonical wire format. Clients should send""and let the server surface"__default__"in responses (which it does at ≥ 2025-04).Solution
Two changes:
sdk.NewIndexConnection: afterpc.Index()creates the connection (where the""→"__default__"coercion happens), immediately re-apply the caller's original namespace viaic.WithNamespace(namespace).WithNamespacesets the field directly, bypassing the coercion. Empty namespace now reaches the gRPC wire as""(proto3 zero value / omitted field), which the server correctly interprets as the default namespace on all versions.--namespaceflag defaults: changed from"__default__"to""across all eight affected commands (index vector query/upsert/update/fetch/delete/listandindex record upsert/search). This makes the CLI default consistent with how the server represents the default namespace (e.g. as shown bypc index stats).Note: the underlying Go SDK also needs a fix — the coercion at
pc.Index()should be removed. The CLI workaround viaWithNamespaceis sufficient for now but the SDK fix should be tracked separately.Type of Change
Test Plan
just test-unitpasses with no failures.pc index stats --index-name <index>on an index with vectors in the default namespace (shows""key), then confirmpc index vector query --index-name <index> --vector '[...]' --top-k 5 --jsonreturns matches (previously required explicit--namespace __default__which itself was broken for some users).