feat(sdk/go): expose tags search filter on Find and Search#2730
Open
r266-tech wants to merge 1 commit into
Open
feat(sdk/go): expose tags search filter on Find and Search#2730r266-tech wants to merge 1 commit into
r266-tech wants to merge 1 commit into
Conversation
The server and Python SDK accept a validated `tags` retrieval filter, but the Go SDK had no way to send it. Add a `Tags []string` option to FindOptions and SearchOptions and forward it as payload["tags"] to /api/v1/search/find and /api/v1/search/search, omitting the key when the slice is empty (mirroring the existing level filter). Follow-up to volcengine#2703, which added since/until/time_field/level to the same Find/Search funcs in the same files the same way.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
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.
What
Adds a
Tags []stringoption to the Go SDKFindOptions/SearchOptionsand forwards it aspayload["tags"]to/api/v1/search/findand/api/v1/search/search, closing a read/filter parity gap: the server and Python SDK accept a validatedtagsretrieval filter that the Go SDK currently cannot send.Why
The server already consumes
tagsend-to-end:openviking/server/routers/search.py—FindRequest.tags/SearchRequest.tags(Optional[List[str]] = None, undermodel_config = ConfigDict(extra="forbid")); the handlers passrequest.tagsintonormalize_search_tags(...)→ asearch_tagsmust-filter.openviking/storage/collection_schemas.py—search_tagsis a first-classlist<string>collection field.openviking/client/local.pyfind(tags=...)/search(tags=...).The Go SDK had no way to send it —
sdk/go/types.goFindOptions/SearchOptionscarriedSince/Until/TimeField/Levelbut noTags, andsdk/go/retrieval.gonever settagsin the payload. So tag-scoped retrieval was unreachable from Go.This is strictly a read/filter parity fix. (Note: the Go SDK does not expose
set_tagseither; tags are populated server-side / via the Pythonset_tagspath / #2706. This PR only lets Go callers filter by tags the server has validated.)Change
types.go: appendTags []stringto both option structs.retrieval.go: inFindandSearch, addif len(opts.Tags) > 0 { payload["tags"] = opts.Tags }right after thelevelblock — omitting the key when empty, exactly mirroring the existing filters.client_test.go: extend the existing filter tests to asserttagsis forwarded when set and absent when unset.Follow-up to #2703, which added
since/until/time_field/levelto the sameFind/Searchfuncs in the same three files the same way.Compatibility
Tagsis appended at the end of the option structs, so it does not reorder or change the type of any existing field. The SDK's option structs are used with keyed literals (e.g.FindOptions{TargetURI: ..., Limit: ...}), which are unaffected; the only theoretical impact is an unkeyed positional literal of these option structs (whichgo vet's composite-literal check already flags for cross-package structs). This matches the additive convention accepted in #2703.Verification
go build ./...,go vet ./...,gofmt -l .(clean), andgo test ./...all pass insdk/go.