Conversation
BrowseSynonyms and BrowseRules pass a *T to the WithAggregator callback (see CreateIterable in the SDK), but GetSynonyms/GetRules asserted to the value type. The comma-ok assertion silently failed on every page, so rules and synonyms were always dropped from `algolia config export`, and scoped exports of only rules/synonyms failed with "No config to export". Every other aggregator callback in this codebase (synonyms/browse, rules/browse, objects/browse, indices/analyze) already asserts to the pointer type; this brings config.go in line with that pattern. Adds unit tests for GetSynonyms, GetRules, and GetIndexConfig, which previously had no test coverage.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 11 |
| Duplication | 0 |
TIP This summary will be updated as you push new changes.
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.
Summary
algolia config exportsilently drops every rule and synonym, and a scope-restricted export of onlyrulesorsynonymsfails withNo config to export.In
pkg/cmd/shared/config/config.go, the aggregator callbacks passed toBrowseSynonyms/BrowseRulesassert the result to a value type:But the SDK's
CreateIterable[T](inalgoliasearch-client-go/v4/algolia/search/api_search.go) always invokes the aggregator with*T:So the comma-ok assertion always fails,
responsestays the zero value, and nothing is ever appended — with no error surfaced anywhere, since the assertion failure is discarded.Every other aggregator in this codebase already asserts to the pointer type (
synonyms/browse,rules/browse,objects/browse,indices/analyze), soconfig.gowas the one outlier.Fix
Assert to
*search.SearchSynonymsResponse/*search.SearchRulesResponse, matching the rest of the codebase, with a nil/ok guard.Test plan
pkg/cmd/shared/config/config_test.gocoveringGetSynonyms,GetRules, andGetIndexConfig(previously zero test coverage in this package)main(proving they actually catch the bug) and pass with the fixgo build ./...andgo vet ./...cleango test ./...— no regressions in any package touched by this change (pre-existing unrelated Windows-path test failures in a fewimportpackages are untouched by this diff)