question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

Describe 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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:8

github_iconTop GitHub Comments

4reactions
pmahoneycommented, Nov 16, 2021

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

1reaction
pmahoneycommented, Nov 16, 2021

The code example works with (at least) @aws-sdk/client-marketplace-entitlement-service@3.6.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unions must have exactly one non-null member. Keys ...
GetEntitlementsCommand fails with TypeError: Unions must have exactly one non-null member. Keys EntitlementValueType,IntegerValue were not null.
Read more >
Marketplace Entitlement Service Client - AWS SDK for ...
The value if it's a number, undefined if it's null/undefined, otherwise an error is thrown. Type declaration. (value: ...
Read more >
ExpectedAttributeValue (AWS SDK for Java - 2.18.33)
AttributeValueList can contain only one AttributeValue element of type String, Number, or Binary (not a set type). If the target attribute of the...
Read more >
@aws-sdk/client-marketplace-entitlement-service-no | npm.io
Check @aws-sdk/client-marketplace-entitlement-service-node 0.1.0-preview.2 package - Last release 0.1.0-preview.2 with Apache-2.0 licence at our NPM p.
Read more >
marketplaceentitlementservice - Go Packages
AWS Marketplace Entitlement Service is used to determine the entitlement of a ... this // member will only be used if the Retryer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found