Skip to content

@aws-sdk/client-iot-data-plane identity.expiration.getTime #5890

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

Closed
3 tasks done
zhex900 opened this issue Mar 14, 2024 · 4 comments
Closed
3 tasks done

@aws-sdk/client-iot-data-plane identity.expiration.getTime #5890

zhex900 opened this issue Mar 14, 2024 · 4 comments
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue

Comments

@zhex900
Copy link

zhex900 commented Mar 14, 2024

Checkboxes for prior research

Describe the bug

@aws-sdk/client-iot-data-plane
after upgrade from ^3.437.0 → ^3.533.0

I start to get this error

"stack":

            TypeError: identity.expiration.getTime is not a function

                at /opt/atlassian/pipelines/agent/build/node_modules/@smithy/core/dist-cjs/index.js:270:154

                at /opt/atlassian/pipelines/agent/build/node_modules/@smithy/core/dist-cjs/index.js:315:9

                at processTicksAndRejections (node:internal/process/task_queues:95:5)

                at /opt/atlassian/pipelines/agent/build/node_modules/@smithy/core/dist-cjs/index.js:82:17

                at /opt/atlassian/pipelines/agent/build/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:33:22

        "message": "identity.expiration.getTime is not a function"

This is how I use it.

    const command = new GetThingShadowCommand({
      thingName,
    });

 const client = new IoTDataPlaneClient({
      endpoint: `https://${process.env.IOT_ENDPOINT}`,
      region: process.env.REGION,
      credentials,
    });

      client.send(command),

SDK version number

@aws-sdk/client-iot-data-plane 3.533.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v18.16.0

Reproduction Steps

    const command = new GetThingShadowCommand({
      thingName,
    });

 const client = new IoTDataPlaneClient({
      endpoint: `https://${process.env.IOT_ENDPOINT}`,
      region: process.env.REGION,
      credentials,
    });

      client.send(command),

Observed Behavior

error

     TypeError: identity.expiration.getTime is not a function

                at /opt/atlassian/pipelines/agent/build/node_modules/@smithy/core/dist-cjs/index.js:270:154

                at /opt/atlassian/pipelines/agent/build/node_modules/@smithy/core/dist-cjs/index.js:315:9

                at processTicksAndRejections (node:internal/process/task_queues:95:5)

                at /opt/atlassian/pipelines/agent/build/node_modules/@smithy/core/dist-cjs/index.js:82:17

                at /opt/atlassian/pipelines/agent/build/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:33:22

        "message": "identity.expiration.getTime is not a function"

Expected Behavior

No error

Possible Solution

No response

Additional Information/Context

No response

@zhex900 zhex900 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 14, 2024
@kuhe
Copy link
Contributor

kuhe commented Mar 14, 2024

if credentials.expiration is set, it must be an instance of the native JavaScript Date class.

@RanVaknin RanVaknin self-assigned this Mar 18, 2024
@RanVaknin RanVaknin added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Mar 18, 2024
@zhex900
Copy link
Author

zhex900 commented Mar 19, 2024

Thank you!

        const url = `https://${process.env.AWS_IOT_CREDENTIALS_ENDPOINT}/role-aliases/${AWS_IOT_CREDENTIALS_ROLE_ALIAS}/credentials`;
        const { data } = await promiseRetry(
          axios.get(url, {
            headers: {
              "x-amzn-iot-thingname": this._deviceId,
            },
            httpsAgent,
          }),
          MAX_RETRY_COUNT,
        );

        this._credentials = {
          ...data?.credentials,
          // this fixed it
          expiration: new Date(data?.credentials?.expiration),
        };

@zhex900 zhex900 closed this as completed Mar 19, 2024
@kuhe kuhe removed the response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. label Mar 20, 2024
@amaValeriya
Copy link

Thank you, @kuhe for the fix!

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

4 participants