aws / aws-sdk-js

AWS SDK for JavaScript in the browser and Node.js (In Maintenance Mode, End-of-Life on 09/08/2025). The AWS SDK for JavaScript v3 in the browser and Node.js is available here: https://github.com/aws/aws-sdk-js-v3
https://aws.amazon.com/developer/language/javascript/
Apache License 2.0
7.6k stars 1.55k forks source link

2.424.0 'Invalid request input' on APIGateway.putIntegrationResponse #2588

Closed gojko closed 5 years ago

gojko commented 5 years ago

since release 2.424.0, putIntegrationResponse in API gateway refuses to execute valid requests containing httpMethod, resourceId, restApiId and statusCode

this works with aws-sdk@2.423.0, but does not work with 2.424.0. (of course, relevant resource IDs need to be set up first)

const aws = require('aws-sdk')
const apig = new aws.APIGateway({region: 'us-west-2'})
apig.putIntegrationResponse({httpMethod: "GET", resourceId: "qlss4p", restApiId: "zrsx0azkpc", statusCode: "200"}).promise()

this is an error thrown from 2.424.0

let resp = apig.putIntegrationResponse({httpMethod: "GET", resourceId: "qlss4p", restApiId: "zrsx0azkpc", statusCode: "200"}).promise().then(console.log).catch(console.error);
undefined
> { BadRequestException: Invalid request input
    at Object.extractError (/Users/gojko/work/claudiajs/claudia/node_modules/aws-sdk/lib/protocol/json.js:51:27)
    at Request.extractError (/Users/gojko/work/claudiajs/claudia/node_modules/aws-sdk/lib/protocol/rest_json.js:55:8)
    at Request.callListeners (/Users/gojko/work/claudiajs/claudia/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/Users/gojko/work/claudiajs/claudia/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/Users/gojko/work/claudiajs/claudia/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/Users/gojko/work/claudiajs/claudia/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/Users/gojko/work/claudiajs/claudia/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Users/gojko/work/claudiajs/claudia/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/Users/gojko/work/claudiajs/claudia/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/Users/gojko/work/claudiajs/claudia/node_modules/aws-sdk/lib/request.js:685:12)
  message: 'Invalid request input',
  code: 'BadRequestException',
  time: 2019-03-20T16:07:50.031Z,
  requestId: '4f173039-4b2a-11e9-a006-dd77bf748a11',
  statusCode: 400,
  retryable: false,
  retryDelay: 18.532212924725357 }
gojko commented 5 years ago

done some more investigation on this, looks like responseTemplates became mandatory in this version. Documentation (https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html#putIntegrationResponse-property) suggests that this should not be mandatory

srchase commented 5 years ago

@gojko

Thanks for the investigation.

It actually looks like this was due to the change here: https://github.com/aws/aws-sdk-js/pull/2574

Starting in 2.424.0, the body for this operation was empty, whereas in 2.423.0 and earlier, the body was {}. The service is failing validation on the empty body in the request.

srchase commented 5 years ago

@gojko

This has been fixed in 2.426.0.

Thanks again for raising this issue.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.