Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using Resp 2 FTAggregateWithArgs does not return an error when using the "as" option #3220

Closed
michaeltch opened this issue Jan 8, 2025 · 2 comments
Assignees
Labels

Comments

@michaeltch
Copy link

I have provided an example program that doesn't panic when the command run on the database should return an error.

Expected Behavior

Panic with error message (error) Unknown argument AS at position 4 for <main>

Current Behavior

The resulting pointer is nil and error is empty causing no panic.
result: 0x0

Steps to Reproduce

package main

import (
	"context"
	"strings"

	"github.com/redis/go-redis/v9"
)

func createIndexAndLoadData(client *redis.Client, ctx context.Context) {
	if _, err := client.FTCreate(ctx,
		"temp",
		&redis.FTCreateOptions{Prefix: []interface{}{"user:"}},
		&redis.FieldSchema{FieldName: "__key", FieldType: redis.SearchFieldTypeText},
	).Result(); err != nil && !strings.Contains(err.Error(), "Index already exists") {
		panic(err)
	}

	if _, err := client.HSet(ctx, "user:1", []string{"__key", "v1"}).Result(); err != nil {
		panic(err)
	}
}

func runAggregateQuery(client *redis.Client, ctx context.Context) {
	filterOpts := &redis.FTAggregateOptions{
		Load: []redis.FTAggregateLoad{
			{
				Field: "@__key",
				As:    "key",
			},
		},
	}
	result, err := client.FTAggregateWithArgs(ctx, "temp", "*", filterOpts).Result()
	if err != nil {
		panic(err)
	}
	println("result:", result)
}

func main() {
	ctx := context.Background()
	client := redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Protocol: 2,
	})

	createIndexAndLoadData(client, ctx)

	runAggregateQuery(client, ctx)
}

Removing the As field fixes the issue and a proper response is returned.

Context (Environment)

Attempting to recreate a separate issue. The database is OSS 6.2.7.

bitsark added a commit to bitsark/go-redis that referenced this issue Jan 9, 2025
* LOAD has NO AS param(https://redis.io/docs/latest/commands/ft.aggregate/)

* fix typo: WITHCOUT -> WITHCOUNT
bitsark added a commit to bitsark/go-redis that referenced this issue Feb 6, 2025
    * Compatible with known RediSearch issue in test
@ndyakov
Copy link
Collaborator

ndyakov commented Feb 6, 2025

Hello @michaeltch, thank you for reporting this!
There were couple of different problems we found with FTAggregateWithArgs. Some are resolved in #3263 , once merged I will check if your case is addressed. I assume an additional fix will be needed to enable As in the Load, but let's see.
cc @bitsark I saw that you were working on this, please use the above PR as a base or wait for it to be merged.

@ndyakov ndyakov self-assigned this Feb 6, 2025
@ndyakov ndyakov added the bug label Feb 6, 2025
bitsark added a commit to bitsark/go-redis that referenced this issue Feb 7, 2025
    * fixed the calculation bug of the count of load params
ndyakov added a commit that referenced this issue Feb 20, 2025
* fix (#3220)

* LOAD has NO AS param(https://redis.io/docs/latest/commands/ft.aggregate/)

* fix typo: WITHCOUT -> WITHCOUNT

* fix (#3220):

    * Compatible with known RediSearch issue in test

* fix (#3220)

    * fixed the calculation bug of the count of load params

* test should not include special condition

* return errors when they occur

---------

Co-authored-by: Nedyalko Dyakov <[email protected]>
Co-authored-by: ofekshenawa <[email protected]>
ndyakov added a commit that referenced this issue Feb 20, 2025
* fix (#3220)

* LOAD has NO AS param(https://redis.io/docs/latest/commands/ft.aggregate/)

* fix typo: WITHCOUT -> WITHCOUNT

* fix (#3220):

    * Compatible with known RediSearch issue in test

* fix (#3220)

    * fixed the calculation bug of the count of load params

* test should not include special condition

* return errors when they occur

---------

Co-authored-by: Nedyalko Dyakov <[email protected]>
Co-authored-by: ofekshenawa <[email protected]>
@ndyakov
Copy link
Collaborator

ndyakov commented Feb 20, 2025

The merge is fixed and we are preparing 9.7.1 release with the fixes.

@ndyakov ndyakov closed this as completed Feb 20, 2025
ndyakov added a commit that referenced this issue Feb 21, 2025
* Add guidance on unstable RESP3 support for RediSearch commands to README (#3177)

* Add UnstableResp3 to docs

* Add RawVal and RawResult to wordlist

* Explain more about SetVal

* Add UnstableResp to wordlist

* Eliminate redundant dial mutex causing unbounded connection queue contention (#3088)

* Eliminate redundant dial mutex causing unbounded connection queue contention

* Dialer connection timeouts unit test

---------

Co-authored-by: ofekshenawa <[email protected]>

* SortByWithCount FTSearchOptions fix (#3201)

* SortByWithCount FTSearchOptions fix

* FTSearch test fix

* Another FTSearch test fix

* Another FTSearch test fix

---------

Co-authored-by: Christopher Golling <[email protected]>

* Fix race condition in clusterNodes.Addrs() (#3219)

Resolve a race condition in the clusterNodes.Addrs() method.
Previously, the method returned a reference to a string slice, creating
the potential for concurrent reads by the caller while the slice was
being modified by the garbage collection process.

Co-authored-by: Nedyalko Dyakov <[email protected]>

* chore: fix some comments (#3226)

Signed-off-by: zhuhaicity <[email protected]>
Co-authored-by: Nedyalko Dyakov <[email protected]>

* fix(aggregate, search): ft.aggregate bugfixes (#3263)

* fix: rearange args for ft.aggregate

apply should be before any groupby or sortby

* improve test

* wip: add scorer and addscores

* enable all tests

* fix ftsearch with count test

* make linter happy

* Addscores is available in later redisearch releases.

For safety state it is available in redis ce 8

* load an apply seem to break scorer and addscores

* fix: add unstableresp3 to cluster client (#3266)

* fix: add unstableresp3 to cluster client

* propagate unstableresp3

* proper test that will ignore error, but fail if client panics

* add separate test for clusterclient constructor

* fix: flaky ClientKillByFilter test (#3268)

* Reinstate read-only lock on hooks access in dialHook (#3225)

* use limit when limitoffset is zero (#3275)

* remove redis 8 comments

* update package versions

* use latest golangci-lint

* fix(search&aggregate):fix error overwrite and typo  #3220 (#3224)

* fix (#3220)

* LOAD has NO AS param(https://redis.io/docs/latest/commands/ft.aggregate/)

* fix typo: WITHCOUT -> WITHCOUNT

* fix (#3220):

    * Compatible with known RediSearch issue in test

* fix (#3220)

    * fixed the calculation bug of the count of load params

* test should not include special condition

* return errors when they occur

---------

Co-authored-by: Nedyalko Dyakov <[email protected]>
Co-authored-by: ofekshenawa <[email protected]>

* Recognize byte slice for key argument in cluster client hash slot computation (#3049)

Co-authored-by: Vladyslav Vildanov <[email protected]>
Co-authored-by: ofekshenawa <[email protected]>

---------

Signed-off-by: zhuhaicity <[email protected]>
Co-authored-by: ofekshenawa <[email protected]>
Co-authored-by: LINKIWI <[email protected]>
Co-authored-by: Cgol9 <[email protected]>
Co-authored-by: Christopher Golling <[email protected]>
Co-authored-by: Shawn Wang <[email protected]>
Co-authored-by: ZhuHaiCheng <[email protected]>
Co-authored-by: herodot <[email protected]>
Co-authored-by: Vladyslav Vildanov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants