Skip to content

Commit 414804a

Browse files
CLOUDP-316626: createSearchIndex command is marshaled incorrectly (#3900)
1 parent ced6b1f commit 414804a

File tree

1 file changed

+5
-2
lines changed
  • internal/cli/deployments/search/indexes

1 file changed

+5
-2
lines changed

internal/cli/deployments/search/indexes/create.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ func (opts *CreateOpts) RunLocal(ctx context.Context) error {
120120
opts.indexID.Collection = index.CollectionName
121121
opts.indexID.Name = index.Name
122122

123-
definition = index.Definition
123+
definition, err = buildIndexDefinition(index.Definition)
124+
if err != nil {
125+
return err
126+
}
124127
case *atlasv2.ClusterSearchIndex:
125128
_, _ = log.Warningln("you're using an old search index definition")
126129
idxType = index.Type
@@ -163,7 +166,7 @@ func (opts *CreateOpts) RunLocal(ctx context.Context) error {
163166
return nil
164167
}
165168

166-
func buildIndexDefinition(idx *atlasv2.ClusterSearchIndex) (any, error) {
169+
func buildIndexDefinition(idx any) (any, error) {
167170
// To maintain formatting of the SDK, marshal object into JSON and then unmarshal into BSON
168171
jsonIndex, err := json.Marshal(idx)
169172
if err != nil {

0 commit comments

Comments
 (0)