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

SQS ReceiveMessageInput.AttributeNames should be of type MessageSystemAttributeName #2124

Closed
denniscfeng opened this issue May 10, 2023 · 4 comments
Assignees
Labels
bug This issue is a bug. p3 This is a minor priority issue service-api This issue is due to a problem in a service API, not the SDK implementation. workaround-available

Comments

@denniscfeng
Copy link

Describe the bug

In the SQS API, the ReceiveMessageInput field AttributeNames should be of type []types.MessageSystemAttributeName instead of []types.QueueAttributeName

https://github.com/aws/aws-sdk-go-v2/blob/main/service/sqs/api_op_ReceiveMessage.go#L96

The documentation indicates the possible fields that can be listed in this argument include ApproximateFirstReceiveTimestamp, ApproximateReceiveCount, SentTimestamp, etc. But those are contained in the type MessageSystemAttributeName, whereas the QueueAttributeName type contains attributes pertaining to the whole queue rather than metadata pertaining to individual messages (MaximumMessageSize, MessageRetentionPeriod, QueueArn).

This prevents us from requesting specific message attributes to be returned with each SQS message.

Expected Behavior

ReceiveMessage should be able to accept a ReceiveMessageInput that includes a list of Attributes that we want to receive with each message. These attributes have been enumerated in types.MessageSystemAttributeName.

Desired:

...
client.ReceiveMessage(ctx, &sqs.ReceiveMessageInput{
		QueueUrl:              aws.String(endpoint),
		WaitTimeSeconds:       5,
		VisibilityTimeout:     10,
		MaxNumberOfMessages:   10,
		MessageAttributeNames: []string{"All"},
		AttributeNames:        []types.MessageSystemAttributeName{types.MessageSystemAttributeNameApproximateReceiveCount},
	})
...

Current Behavior

Cannot use '[]types.MessageSystemAttributeName{types.MessageSystemAttributeNameApproximateReceiveCount}' (type []types.MessageSystemAttributeName) as type []types.QueueAttributeName

Reproduction Steps

package test

import (
	"context"
	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/config"
	"github.com/aws/aws-sdk-go-v2/service/sqs"
	"github.com/aws/aws-sdk-go-v2/service/sqs/types"
	"testing"
)

func Test(t *testing.T)  {
	cfg, err := config.LoadDefaultConfig(
		context.TODO(),
		config.WithRegion("us-west2"),
	)
	if err != nil {
		t.Fail()
	}
	
	sqsClient := sqs.NewFromConfig(cfg)
	_, _ = sqsClient.ReceiveMessage(context.TODO(), &sqs.ReceiveMessageInput{
		QueueUrl:              aws.String("queue url"),
		WaitTimeSeconds:       5,
		VisibilityTimeout:     10,
		MaxNumberOfMessages:   10,
		MessageAttributeNames: []string{"All"},
		AttributeNames:        []types.MessageSystemAttributeName{types.MessageSystemAttributeNameApproximateReceiveCount},
	})
}

Possible Solution

Change the type of ReceiveMessageInput.AttributeNames from []types.QueueAttributeName to []types.MessageSystemAttributeName

Additional Information/Context

No response

AWS Go SDK V2 Module Versions Used

        github.com/aws/aws-sdk-go v1.39.1
        github.com/aws/aws-sdk-go-v2 v1.18.0
        github.com/aws/aws-sdk-go-v2/config v1.18.22
        github.com/aws/aws-sdk-go-v2/service/sqs v1.22.0
        github.com/aws/aws-sdk-go-v2/credentials v1.13.21 // indirect
        github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3 // indirect
        github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33 // indirect
        github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27 // indirect
        github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34 // indirect
        github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.27 // indirect
        github.com/aws/aws-sdk-go-v2/service/sso v1.12.9 // indirect
        github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.9 // indirect
        github.com/aws/aws-sdk-go-v2/service/sts v1.18.10 // indirect
        github.com/aws/smithy-go v1.13.5 // indirect

Compiler and Version used

go version go1.17.13 darwin/amd64

Operating System and version

macOS Big Sur Version 11.7.6

@denniscfeng denniscfeng added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 10, 2023
@aajtodd
Copy link
Contributor

aajtodd commented May 11, 2023

This does indeed look like a model issue (the type is correct but it should include all possible values in the QueueAttributeName enum in the model, which overlaps with MessageSystemAttrributeName) but you can workaround it for now by using the raw string values:

_, _ = sqsClient.ReceiveMessage(context.TODO(), &sqs.ReceiveMessageInput{
    ...
    AttributeNames: []types.QueueAttributeName{ types.QueueAttributeName("ApproximateReceiveCount") },
})

related: awslabs/aws-sdk-kotlin#857 (comment)

@aajtodd aajtodd added p3 This is a minor priority issue and removed needs-triage This issue or PR still needs to be triaged. labels May 11, 2023
@RanVaknin RanVaknin self-assigned this May 11, 2023
@lucix-aws lucix-aws added the service-api This issue is due to a problem in a service API, not the SDK implementation. label Feb 13, 2024
@mwillfox
Copy link

This seems like a really simple bug to fix...any plans on getting it fixed in a release at some point soon?

@RanVaknin
Copy link
Contributor

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

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. p3 This is a minor priority issue service-api This issue is due to a problem in a service API, not the SDK implementation. workaround-available
Projects
None yet
Development

No branches or pull requests

5 participants