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

Errors when compiling TimeStreamQuery related functions #2401

Closed
porrige51122 opened this issue Dec 1, 2023 · 2 comments
Closed

Errors when compiling TimeStreamQuery related functions #2401

porrige51122 opened this issue Dec 1, 2023 · 2 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@porrige51122
Copy link

porrige51122 commented Dec 1, 2023

Describe the bug

Issue in compilation of any code using the timestreamquery service.

When compiling, it throws a large amount of errors, all seemingly related to the "c.fetchOpListScheduledQueriesDiscoverEndpoint"

Expected Behavior

Compiled without errors. In the code snippet below the aim is to simply query the database and check it has more than one entry

Current Behavior

This error was thrown

❯ go test -v                 
# github.com/aws/aws-sdk-go-v2/service/timestreamquery
.../go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/api_op_CancelQuery.go:150:33: cannot use c.fetchOpCancelQueryDiscoverEndpoint (value of type func(ctx "context".Context, optFns ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error)) as func(ctx "context".Context, region string, options ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error) value in struct literal
.../go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/api_op_CreateScheduledQuery.go:214:33: cannot use c.fetchOpCreateScheduledQueryDiscoverEndpoint (value of type func(ctx "context".Context, optFns ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error)) as func(ctx "context".Context, region string, options ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error) value in struct literal
.../go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/api_op_DeleteScheduledQuery.go:139:33: cannot use c.fetchOpDeleteScheduledQueryDiscoverEndpoint (value of type func(ctx "context".Context, optFns ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error)) as func(ctx "context".Context, region string, options ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error) value in struct literal
.../go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/api_op_DescribeScheduledQuery.go:146:33: cannot use c.fetchOpDescribeScheduledQueryDiscoverEndpoint (value of type func(ctx "context".Context, optFns ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error)) as func(ctx "context".Context, region string, options ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error) value in struct literal
.../go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/api_op_ExecuteScheduledQuery.go:151:33: cannot use c.fetchOpExecuteScheduledQueryDiscoverEndpoint (value of type func(ctx "context".Context, optFns ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error)) as func(ctx "context".Context, region string, options ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error) value in struct literal
.../go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/api_op_ListScheduledQueries.go:152:33: cannot use c.fetchOpListScheduledQueriesDiscoverEndpoint (value of type func(ctx "context".Context, optFns ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error)) as func(ctx "context".Context, region string, options ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error) value in struct literal
.../go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/api_op_ListTagsForResource.go:157:33: cannot use c.fetchOpListTagsForResourceDiscoverEndpoint (value of type func(ctx "context".Context, optFns ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error)) as func(ctx "context".Context, region string, options ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error) value in struct literal
.../go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/api_op_PrepareQuery.go:165:33: cannot use c.fetchOpPrepareQueryDiscoverEndpoint (value of type func(ctx "context".Context, optFns ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error)) as func(ctx "context".Context, region string, options ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error) value in struct literal
.../go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/api_op_Query.go:234:33: cannot use c.fetchOpQueryDiscoverEndpoint (value of type func(ctx "context".Context, optFns ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error)) as func(ctx "context".Context, region string, options ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error) value in struct literal
.../go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/api_op_TagResource.go:148:33: cannot use c.fetchOpTagResourceDiscoverEndpoint (value of type func(ctx "context".Context, optFns ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error)) as func(ctx "context".Context, region string, options ...func(*endpointdiscovery.DiscoverEndpointOptions)) (endpointdiscovery.WeightedAddress, error) value in struct literal
.../go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/api_op_TagResource.go:148:33: too many errors
FAIL    my-test[build failed]

Reproduction Steps

run a go test on this and the error will be recreated.

package module_test

import (
	"context"
	"fmt"
	"testing"

	"github.com/aws/aws-sdk-go-v2/config"
	"github.com/aws/aws-sdk-go-v2/service/timestreamquery"
	"github.com/aws/aws-sdk-go/aws"

	"github.com/stretchr/testify/require"
)

func TestModule(t *testing.T) {
	// Create AWS Session for testing
	ctx := context.Background()
	cfg, err := config.LoadDefaultConfig(ctx)
	require.Nil(t, err, "Error loading AWS config")
	timestreamQueryClient := timestreamquery.NewFromConfig(cfg, func(o *timestreamquery.Options) {
		o.Region = "eu-west-1"
	})

	dbName := "hello-world"
	tableName := "hello-world"

	// Assert Data has been written to Timestream
	t.Run("CheckTimestreamDataExists", func(t *testing.T) {
		CheckTimestreamDataExists(t, ctx, timestreamQueryClient, dbName, tableName)
	})
}

// Function to check if data has been written to timestream
func CheckTimestreamDataExists(t *testing.T, ctx context.Context, client *timestreamquery.Client, databaseName string, tableName string) {
	output, err := client.Query(ctx, &timestreamquery.QueryInput{
		QueryString: aws.String(fmt.Sprintf("SELECT * FROM \"%s\".\"%s\"", databaseName, tableName)),
	})
	if err != nil {
		fmt.Println(err.Error())
	}
	require.Nil(t, err, "Error getting timestream data")

	// Assert that more than 0 records have been returned
	require.Greater(t, len(output.Rows), 0, "No data returned from timestream")
}

Possible Solution

This error has only started happening in the latest version. Therefore when the fix occured for a different bug, this bug was introduced.

Additional Information/Context

This was using a query against a database. I have written a test that queries that data exists in a table for an integration test.

AWS Go SDK V2 Module Versions Used

module test-module-int

go 1.21

require (
	github.com/aws/aws-sdk-go v1.48.10
	github.com/aws/aws-sdk-go-v2/config v1.25.10
	github.com/aws/aws-sdk-go-v2/service/timestreamquery v1.19.2
	github.com/stretchr/testify v1.8.4
)

require (
	github.com/aws/aws-sdk-go-v2 v1.23.4 // indirect
	github.com/aws/aws-sdk-go-v2/credentials v1.16.8 // indirect
	github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.8 // indirect
	github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.7 // indirect
	github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.7 // indirect
	github.com/aws/aws-sdk-go-v2/internal/ini v1.7.1 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.3 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.8.8 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.7 // indirect
	github.com/aws/aws-sdk-go-v2/service/sso v1.18.1 // indirect
	github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.1 // indirect
	github.com/aws/aws-sdk-go-v2/service/sts v1.26.1 // indirect
	github.com/aws/smithy-go v1.18.1 // indirect
	github.com/davecgh/go-spew v1.1.1 // indirect
	github.com/google/go-cmp v0.6.0 // indirect
	github.com/kr/pretty v0.3.0 // indirect
	github.com/pmezard/go-difflib v1.0.0 // indirect
	github.com/rogpeppe/go-internal v1.10.0 // indirect
	gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
	gopkg.in/yaml.v3 v3.0.1 // indirect
)

Compiler and Version used

go version go1.21.4 darwin/arm64

Operating System and version

macOS Ventura 13.5.2

@porrige51122 porrige51122 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 1, 2023
@lucix-aws
Copy link
Contributor

@porrige51122 The signature of an API in the internal package endpoint-discovery was changed in 1.8.8 (from the latest release https://github.com/aws/aws-sdk-go-v2/releases/tag/release-2023-11-30.2) to facilitate the fix of #2163 . Versions of endpoint discovery released before yesterday will no longer be compatible, which includes the timestreamquery v1.19.2 version your example is using.

You'll need to upgrade any dependencies of timestreamwrite, timestreamquery, or dynamodb (these are the only affected services) to the latest versions (1.23.2, 1.20.2, and 1.26.2 respectively).

Copy link

github-actions bot commented Dec 1, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants