aws-sdk-js icon indicating copy to clipboard operation
aws-sdk-js copied to clipboard

MediaConvert input validation error

Open joshbooks opened this issue 3 years ago • 3 comments

Describe the bug

JS sdk parameter validation fails on the 'videoGenerator/VideoGenerator" key in the input object, which is strange because I took it from the json of a working job I created through the console

Expected Behavior

I expected that the VideoGenerator to be an allowable attribute of the input object based on this code

Current Behavior

"UnexpectedParameter: Unexpected key 'videoGenerator' found in params.Settings.Inputs[0]",         "    at
ParamValidator.fail (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:50:37)",         "    at
ParamValidator.validateStructure (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:78:14)",         "    at
ParamValidator.validateMember (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:89:21)",         "    at
ParamValidator.validateList (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:104:14)",         "    at
ParamValidator.validateMember (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:91:21)",         "    at
ParamValidator.validateStructure (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:76:14)",         "    at
ParamValidator.validateMember (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:89:21)",         "    at
ParamValidator.validateStructure (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:76:14)",         "    at
ParamValidator.validateMember (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:89:21)",         "    at
ParamValidator.validate (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:34:10)"     ] } | 2022-10-10T05:37:28.829Z f7e6d676-977f-4adf-9cb1-66272fa11dff 
ERROR Invoke Error {"errorType":"UnexpectedParameter","errorMessage":"Unexpected key 'videoGenerator' found in params.Settings.Inputs[0]","code":"UnexpectedParameter","message":"Unexpected key 'videoGenerator' found in params.Settings.Inputs[0]","time":"2022-10-10T05:37:28.828Z","stack":["UnexpectedParameter: Unexpected key 'videoGenerator' found in params.Settings.Inputs[0]"," at ParamValidator.fail (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:50:37)"," at ParamValidator.validateStructure (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:78:14)"," at ParamValidator.validateMember (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:89:21)"," at ParamValidator.validateList (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:104:14)"," at ParamValidator.validateMember (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:91:21)"," at ParamValidator.validateStructure (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:76:14)"," at ParamValidator.validateMember (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:89:21)"," at ParamValidator.validateStructure (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:76:14)"," at ParamValidator.validateMember (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:89:21)"," at ParamValidator.validate (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:34:10)"]}
-- | --

Reproduction Steps

create a job using this code:

const createJob = async (job, endpoint) => {
    const mediaconvert = new AWS.MediaConvert({
        endpoint: endpoint,
        customUserAgent: process.env.SOLUTION_IDENTIFIER
    });
    try {
        await mediaconvert.createJob(job).promise();
        console.log(`job subbmited to MediaConvert:: ${JSON.stringify(job, null, 2)}`);
    } catch (err) {
        throw err;
    }
    return;
};

and this configuration (with an image and destination you have access to, can probably delete encryption stuff):

{
  "Queue": "arn:aws:mediaconvert:us-east-1:893309370235:queues/Default",
  "UserMetadata": {},
  "Role": "arn:aws:iam::893309370235:role/EZDRM",
  "Settings": {
    "TimecodeConfig": {
      "Source": "ZEROBASED"
    },
    "OutputGroups": [
      {
        "Name": "DASH ISO",
        "Outputs": [
          {
            "ContainerSettings": {
              "Container": "MPD"
            },
            "VideoDescription": {
              "Width": 760,
              "Height": 1064,
              "VideoPreprocessors": {
                "ImageInserter": {
                  "InsertableImages": [
                    {
                      "ImageX": 0,
                      "ImageY": 0,
                      "Duration": 1000,
                      "Layer": 99,
                      "ImageInserterInput": "s3://sof-test-user-content/Kevin.png",
                      "StartTime": "00:00:00:00",
                      "Opacity": 100
                    }
                  ]
                }
              },
              "CodecSettings": {
                "Codec": "H_264",
                "H264Settings": {
                  "FramerateDenominator": 1,
                  "MaxBitrate": 300000,
                  "FramerateControl": "SPECIFIED",
                  "RateControlMode": "QVBR",
                  "FramerateNumerator": 60,
                  "SceneChangeDetect": "TRANSITION_DETECTION"
                }
              }
            },
            "NameModifier": "_output1"
          },
          {
            "ContainerSettings": {
              "Container": "MPD"
            },
            "AudioDescriptions": [
              {
                "CodecSettings": {
                  "Codec": "AAC",
                  "AacSettings": {
                    "Bitrate": 96000,
                    "CodingMode": "CODING_MODE_2_0",
                    "SampleRate": 48000
                  }
                }
              }
            ],
            "NameModifier": "_output2"
          }
        ],
        "OutputGroupSettings": {
          "Type": "DASH_ISO_GROUP_SETTINGS",
          "DashIsoGroupSettings": {
            "SegmentLength": 30,
            "Destination": "s3://destinationbucket/guid/widevine",
            "Encryption": {
              "SpekeKeyProvider": {
                "ResourceId": "uniqueenough",
                "SystemIds": [
                  "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",
                  "9a04f079-9840-4286-ab92-e65be0885f95"
                ],
                "Url": "https://koc7yft7p5.execute-api.us-east-1.amazonaws.com/production/copyprotection"
              }
            },
            "FragmentLength": 6,
            "SegmentControl": "SEGMENTED_FILES"
          }
        }
      }
    ],
    "Inputs": [
      {
        "AudioSelectors": {
          "Audio Selector 1": {
            "DefaultSelection": "DEFAULT"
          }
        },
        "VideoSelector": {},
        "videoGenerator": {"duration": 1000}
      }
    ]
  },
  "AccelerationSettings": {
    "Mode": "DISABLED"
  },
  "StatusUpdateInterval": "SECONDS_60",
  "Priority": 0
}

Possible Solution

genuinely not sure

Additional Information/Context

No response

SDK version used

default included in Node.js 16.x lambda runtime

Environment details (OS name and version, etc.)

lambda Node.js 16.x

joshbooks avatar Oct 10 '22 05:10 joshbooks

Hey @joshbooks thanks for opening this issue, I see that error is coming from when the param is somehow undefined or null. https://github.com/aws/aws-sdk-js/blob/bfb3aaf792c8e50962004a72f090f4fb067d2c27/lib/param_validator.js#L61 Which from the code you mentioned seems to not be the case (undefined or null for videoGenerator). MediaConvert has also introduced a bunch of features between 2.1083 and the latest. Can you try it with the latest version of the SDK? I will try to reproduce the same with the latest version.

To use the latest version of SDK with Lambda: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html

ajredniwja avatar Oct 15 '22 06:10 ajredniwja

@ajredniwja executed with latest aws sdk version (2.1233.0) and got the same issue:

2022-10-16T21:47:14.067Z	43deff7b-1cc0-496c-aee4-539207bfa94c	ERROR	Invoke Error 	
{
    "errorType": "UnexpectedParameter",
    "errorMessage": "Unexpected key 'videoGenerator' found in params.Settings.Inputs[0]",
    "code": "UnexpectedParameter",
    "message": "Unexpected key 'videoGenerator' found in params.Settings.Inputs[0]",
    "time": "2022-10-16T21:47:14.066Z",
    "stack": [
        "UnexpectedParameter: Unexpected key 'videoGenerator' found in params.Settings.Inputs[0]",
        "    at ParamValidator.fail (/opt/nodejs/node_modules/aws-sdk/lib/param_validator.js:50:37)",
        "    at ParamValidator.validateStructure (/opt/nodejs/node_modules/aws-sdk/lib/param_validator.js:78:14)",
        "    at ParamValidator.validateMember (/opt/nodejs/node_modules/aws-sdk/lib/param_validator.js:89:21)",
        "    at ParamValidator.validateList (/opt/nodejs/node_modules/aws-sdk/lib/param_validator.js:104:14)",
        "    at ParamValidator.validateMember (/opt/nodejs/node_modules/aws-sdk/lib/param_validator.js:91:21)",
        "    at ParamValidator.validateStructure (/opt/nodejs/node_modules/aws-sdk/lib/param_validator.js:76:14)",
        "    at ParamValidator.validateMember (/opt/nodejs/node_modules/aws-sdk/lib/param_validator.js:89:21)",
        "    at ParamValidator.validateStructure (/opt/nodejs/node_modules/aws-sdk/lib/param_validator.js:76:14)",
        "    at ParamValidator.validateMember (/opt/nodejs/node_modules/aws-sdk/lib/param_validator.js:89:21)",
        "    at ParamValidator.validate (/opt/nodejs/node_modules/aws-sdk/lib/param_validator.js:34:10)"
    ]
}

joshbooks avatar Oct 16 '22 21:10 joshbooks

looks like the member shape for this expects PascalCase "VideoGenerator": { Duration: 1000 } and not camelCase, though both are allowable when directly creating through the console, changing to PascalCase fixed the validation error for me

joshbooks avatar Oct 16 '22 23:10 joshbooks

Hi there - apologies for the long silence.

The issue is due to the AWS MediaConvert API's requirement to use PascalCase for the keys in the input objects which the AWS SDK for JavaScript strictly adheres to. The SDK follows the API specification precisely whereas the AWS Management Console may be more lenient in accepting different casing conventions.

If you would like to provide feedback or suggestions regarding the casing requirements for the MediaConvert API, I can reach out to the MediaConvert team on your behalf. Alternatively, you can reach out to the service team directly through AWS Support.

Since this issue is not directly related to the AWS SDK itself and this repo is dedicated to handling SDK-related matters, I will proceed with closing this issue.

aBurmeseDev avatar Aug 29 '24 18:08 aBurmeseDev