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

Lexv2 client RecognizeUtterance signature problem #1029

Closed
ThinSnorlax opened this issue Aug 23, 2023 · 5 comments · Fixed by smithy-lang/smithy-kotlin#934
Closed

Lexv2 client RecognizeUtterance signature problem #1029

ThinSnorlax opened this issue Aug 23, 2023 · 5 comments · Fixed by smithy-lang/smithy-kotlin#934
Labels
bug This issue is a bug.

Comments

@ThinSnorlax
Copy link

Describe the bug

Dear team

I use lexv2runtime.RecognizeUtterance funtion to call recognizeUtterance but I meet a error;
the error:

aws.sdk.kotlin.services.lexruntimev2.model.LexRuntimeV2Exception: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
                                                                                                    	at aws.sdk.kotlin.services.lexruntimev2.transform.RecognizeUtteranceOperationDeserializerKt.throwRecognizeUtteranceError(RecognizeUtteranceOperationDeserializer.kt:64)
                                                                                                    	at aws.sdk.kotlin.services.lexruntimev2.transform.RecognizeUtteranceOperationDeserializerKt.access$throwRecognizeUtteranceError(RecognizeUtteranceOperationDeserializer.kt:1)
                                                                                                    	at aws.sdk.kotlin.services.lexruntimev2.transform.RecognizeUtteranceOperationDeserializerKt$throwRecognizeUtteranceError$1.invokeSuspend(Unknown Source:13)
                                                                                                    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                    	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
                                                                                                    	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@2fe4572, Dispatchers.Default]

This is my code:

 fun testRecognizeUtterance() {
        val client = LexRuntimeV2Client {
            region = "us-east-1"
            credentialsProvider = SnxCredentialsProvider()
        }
        val request = RecognizeUtteranceRequest {
            botId="CR36NPE9E9"
            botAliasId="TSTALIASID"
            localeId="en_US"
            sessionId="snxtest"
            requestContentType="text/plain; charset=utf-8"
            inputStream= ByteStream.fromString("Hello, I'm your father")
        }
        GlobalScope.launch() {
            println("start request")
            client.recognizeUtterance(request, {
                println("The status is ${it.messages.toString()}")
            })
            println("finish request")
        }
    }

And I can run python code by the same paramaters, access key and security key are the same of kotlin, too
python code:

def test_lex():
    lex = boto3.client('lexv2-runtime', region_name='us-east-1')
    bot_id = 'CR36NPE9E9'
    response = lex.recognize_utterance(
        botId=bot_id,
        botAliasId='TSTALIASID',
        localeId='en_US',
        sessionId='snxtest',
        requestContentType='text/plain; charset=utf-8',
        inputStream=b'hello'
    )
    print(response)

Expected behavior

I can print lexv2runtime.RecognizeUtterance response;
And the python response is like below of:

{
	'ResponseMetadata': {
		'RequestId': 'bd070710-e0a5-456e-81a0-6fe56a8a1d0a',
		'HTTPStatusCode': 200,
		'HTTPHeaders': {
			'x-amzn-requestid': 'bd070710-e0a5-456e-81a0-6fe56a8a1d0a',
			'strict-transport-security': 'max-age=31536000; includeSubDomains',
			'x-amz-lex-input-mode': 'Text',
			'x-amz-lex-interpretations': 'H4sIAAAAAAAA/4WOMQvCMBBG/8vNQUTEIaOFoouDjuJwplcIvd5Bch0k5L9LqYMi4vw93veuBaIYiYEvIDgSeGiR+Y5hOC6Dg8xqGXypDrKhzcyZsHu0mtqJ+8g8LmBQ6WMa0aLK5UWeVAhqdQWEp2YGOpJA818Omgj8erXbVvfdsVcdDmrE7wl/TNvNL1OD6dNzewL+7P+W/AAAAA==',
			'x-content-type-options': 'nosniff',
			'x-amz-lex-session-id': 'snxtest',
			'x-amz-lex-session-state': 'H4sIAAAAAAAA/y2NQQqDQAwA/5KzwgrVirdSEHrpwb4gulFC16TdjYci/r1Ye55hZgXPGHS6DMYq0KxgnxdBA9egiWDLgMVIbCeC805aDKHH4Xk7QAYpqCVo1i2DZGi70xH6T6uxXcLIIcyHOKiMHGfcV4+/eVf5bRKlxCoXs8j9YvQPauSJBY1l6ui9ULKbhwZ6787uXLicHJb5qaworwt0eTVSWWGNhXcI2xeh2azu3QAAAA==',
			'date': 'Wed, 23 Aug 2023 07:16:42 GMT',
			'content-type': 'text/plain; charset=utf-8',
			'content-length': '0',
			'connection': 'keep-alive'
		},
		'RetryAttempts': 0
	},
	'inputMode': 'Text',
	'contentType': 'text/plain; charset=utf-8',
	'interpretations': 'H4sIAAAAAAAA/4WOMQvCMBBG/8vNQUTEIaOFoouDjuJwplcIvd5Bch0k5L9LqYMi4vw93veuBaIYiYEvIDgSeGiR+Y5hOC6Dg8xqGXypDrKhzcyZsHu0mtqJ+8g8LmBQ6WMa0aLK5UWeVAhqdQWEp2YGOpJA818Omgj8erXbVvfdsVcdDmrE7wl/TNvNL1OD6dNzewL+7P+W/AAAAA==',
	'sessionState': 'H4sIAAAAAAAA/y2NQQqDQAwA/5KzwgrVirdSEHrpwb4gulFC16TdjYci/r1Ye55hZgXPGHS6DMYq0KxgnxdBA9egiWDLgMVIbCeC805aDKHH4Xk7QAYpqCVo1i2DZGi70xH6T6uxXcLIIcyHOKiMHGfcV4+/eVf5bRKlxCoXs8j9YvQPauSJBY1l6ui9ULKbhwZ6787uXLicHJb5qaworwt0eTVSWWGNhXcI2xeh2azu3QAAAA==',
	'sessionId': 'snxtest',
	'audioStream': < botocore.response.StreamingBody object at 0x10eaeb280 >
}

Current behavior

The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.

Steps to Reproduce

every time

Possible Solution

No response

Context

No response

AWS Kotlin SDK version used

0.30.1-beta

Platform (JVM/JS/Native)

JVM

Operating System and version

Android 13, MIUI14

@ThinSnorlax ThinSnorlax added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 23, 2023
@aajtodd aajtodd removed the needs-triage This issue or PR still needs to be triaged. label Aug 23, 2023
@aajtodd
Copy link
Contributor

aajtodd commented Aug 23, 2023

Thanks for the report, I've been able to reproduce this and am looking into it further.

@aajtodd
Copy link
Contributor

aajtodd commented Aug 23, 2023

The request is missing the x-amz-content-sha256 header, I have a PR up and the fix should be available in the next release.

@github-actions
Copy link

⚠️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.

@ThinSnorlax
Copy link
Author

@aajtodd Thanks very much
When will the next version be released?

@aajtodd
Copy link
Contributor

aajtodd commented Aug 24, 2023

Hopefully today

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.
Projects
None yet
2 participants