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

dynamodb/expression: name builder for list of lists: foo[10][5] returns: BuildOperand error: invalid parameter: NameBuilder #2078

Open
advanderveer opened this issue Apr 1, 2023 · 1 comment
Assignees
Labels
bug This issue is a bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 This is a standard priority issue

Comments

@advanderveer
Copy link

Describe the bug

As far as I understand it is possible to model a list of lists in dynamodb. So it should be possible to build a name (as part of a condition for example), with something like the code below. Instead, it errors:

package generator_test

import (
	"testing"

	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression"
)

func TestNameBuilder(t *testing.T) {
	expr, err := expression.NewBuilder().WithCondition(expression.Name("foo[10][5]").AttributeExists()).Build()
	if err != nil {
		t.Fatalf("failed: %v", err) // BuildOperand error: invalid parameter: NameBuilder
	}
	_ = expr
}

Expected Behavior

It should allow building names for a list of lists

Current Behavior

It returns the following error:

BuildOperand error: invalid parameter: NameBuilder

Reproduction Steps

The code above can be pasted into a _test.go file to get the error.

Possible Solution

No response

Additional Information/Context

No response

AWS Go SDK V2 Module Versions Used

github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.19
github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.4.46
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.19.2

Compiler and Version used

go version go1.20.2 darwin/arm64

Operating System and version

MacOS Ventura 13.1

@advanderveer advanderveer added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 1, 2023
@jmklix jmklix added p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Apr 5, 2023
@jmklix jmklix self-assigned this Apr 5, 2023
@jmklix jmklix added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Apr 5, 2023
@lucix-aws lucix-aws added needs-triage This issue or PR still needs to be triaged. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 This is a standard priority issue labels Sep 17, 2023
@RanVaknin RanVaknin assigned RanVaknin and unassigned jmklix Sep 20, 2023
@RanVaknin
Copy link
Contributor

Hi @advanderveer ,

Sorry for the long wait.

I'm able to confirm that nested expressions are not supported. This was probably an oversight with how this feature was implemented.

As a workaround you can pass in the expression directly to the getItemInput:

package main

import (
	"context"
	"github.com/aws/aws-sdk-go-v2/aws"
	"log"

	"github.com/aws/aws-sdk-go-v2/config"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
)

func main() {
	cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithClientLogMode(aws.LogRequestWithBody|aws.LogResponseWithBody))
	if err != nil {
		log.Fatalf("unable to load SDK config, %v", err)
	}

	client := dynamodb.NewFromConfig(cfg)

	params := &dynamodb.GetItemInput{
		TableName:            aws.String("nestedExpressionTable"),
		Key:                  map[string]types.AttributeValue{"PrimaryKey": &types.AttributeValueMemberS{Value: "SomeKey"}},
		ProjectionExpression: aws.String("foo[2][5]"),
	}

	_, err = client.GetItem(context.TODO(), params)
	if err != nil {
		log.Fatalf("failed to get item, %v", err)
	}
}

Will result in a valid response:

{"Item":{"foo":{"L":[{"L":[{"N":"96"}]}]}}}

I'll discuss this with the team for further investigation.

Thanks,
Ran~

@RanVaknin RanVaknin added needs-review This issue or pull request needs review from a core team member. p2 This is a standard priority issue investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. needs-review This issue or pull request needs review from a core team member. labels Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

4 participants