client-marketplace-entitlement-service: GetEntitlementsCommand fails with TypeError: Unions must have exactly one non-null member. Keys EntitlementValueType,IntegerValue were not null
See original GitHub issueDescribe the bug
client-marketplace-entitlement-service: GetEntitlementsCommand fails with TypeError: Unions must have exactly one non-null member. Keys EntitlementValueType,IntegerValue were not null
Your environment
- Linux
- node 14
- typescript 4.4.4
SDK version number
@aws-sdk/client-marketplace-entitlement-service@3.41.0
Is the issue in the browser/Node.js/ReactNative?
Node.js
Details of the browser/Node.js/ReactNative version
Paste output of npx envinfo --browsers
or node -v
or react-native -v
node -v
v14.18.0
Steps to reproduce
Edit the code to add a real productCode and customerIdentifier, then run with node.
const aws = require('@aws-sdk/client-marketplace-entitlement-service');
const marketplaceEntitlementServiceClient =
new aws.MarketplaceEntitlementServiceClient({
region: 'us-east-1',
});
const productCode = '<code>';
const customerIdentifier = '<id>';
(async () => {
try {
const out = await marketplaceEntitlementServiceClient.send(
new aws.GetEntitlementsCommand({
ProductCode: productCode,
Filter: {
CUSTOMER_IDENTIFIER: [customerIdentifier],
},
}));
console.log(out);
} catch (e) {
console.log(e);
}
})();
Observed behavior
TypeError: Unions must have exactly one non-null member. Keys EntitlementValueType,IntegerValue were not null.
at Object.expectUnion (/app/node_modules/@aws-sdk/client-marketplace-entitlement-service/node_modules/@aws-sdk/smithy-client/dist-cjs/parse-utils.js:122:15)
at deserializeAws_json1_1Entitlement (/app/node_modules/@aws-sdk/client-marketplace-entitlement-service/dist-cjs/protocols/Aws_json1_1.js:152:70)
at /app/node_modules/@aws-sdk/client-marketplace-entitlement-service/dist-cjs/protocols/Aws_json1_1.js:163:16
at Array.map (<anonymous>)
at deserializeAws_json1_1EntitlementList (/app/node_modules/@aws-sdk/client-marketplace-entitlement-service/dist-cjs/protocols/Aws_json1_1.js:159:10)
at deserializeAws_json1_1GetEntitlementsResult (/app/node_modules/@aws-sdk/client-marketplace-entitlement-service/dist-cjs/protocols/Aws_json1_1.js:184:15)
at Object.deserializeAws_json1_1GetEntitlementsCommand (/app/node_modules/@aws-sdk/client-marketplace-entitlement-service/dist-cjs/protocols/Aws_json1_1.js:22:16)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async /app/node_modules/@aws-sdk/client-marketplace-entitlement-service/node_modules/@aws-sdk/middleware-serde/dist-cjs/deserializerMiddleware.js:6:20
at async /app/node_modules/@aws-sdk/client-marketplace-entitlement-service/node_modules/@aws-sdk/middleware-signing/dist-cjs/middleware.js:11:20 {
'$metadata': { attempts: 1, totalRetryDelay: 0 }
}
Expected behavior
Return an object containing the Entitlements.
Additional context
The commandline client aws marketplace-entitlement get-entitlements --product-code <code> --filter CUSTOMER_IDENTIFIER=<id>
succeeds with the same AWS credentials and same product code and customer id. It prints:
{
"Entitlements": [
{
"ProductCode": "<code>",
"Dimension": "free_trial",
"CustomerIdentifier": "<id>",
"Value": {
"IntegerValue": 1
},
"ExpirationDate": "2021-12-15T15:23:20.371000-06:00"
}
]
}
By adding log output to parse_utils.js
, I see that prior to the call to expectUnion()
, the data is:
{
CustomerIdentifier: '<id>',
Dimension: 'free_trial',
ExpirationDate: 1639603400.371,
ProductCode: '<code>',
Value: { EntitlementValueType: 'int', IntegerValue: 1 }
}
I also asked this on same question on StackOverflow, but at this point it seems like a bug.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:8
I’ve narrowed it down:
The code example fails with
@aws-sdk/client-marketplace-entitlement-service@3.31.0
The code example works with@aws-sdk/client-marketplace-entitlement-service@3.30.0
The code example works with (at least)
@aws-sdk/client-marketplace-entitlement-service@3.6.1