Skip to content

Conversation

smilkuri
Copy link
Contributor

@smilkuri smilkuri commented Sep 2, 2025

Issue

#7297

Description

  • FromHttpOptions extends CredentialProviderOptions which has an optional Logger interface. When users provide class-based logger without binding breaks the this context resulting in Cannot read properties of undefined errors, if the logger is an object that references other members.
  • Added .bind(options.logger) to preserve method context.

Testing

Locally

yarn test:all
Tasks:    516 successful, 516 total
Cached:    516 cached, 516 total
  Time:    25.9s >>> FULL TURBO

 PASS  packages/signature-v4-crt/src/CrtSignerV4.spec.ts
 PASS  packages/signature-v4-crt/src/crtSuite.spec.ts

Test Suites: 2 passed, 2 total
Tests:       25 passed, 25 total
Snapshots:   0 total
Time:        4.837 s, estimated 5 s
Ran all test suites.
lerna notice cli v5.5.2
lerna notice filter including "@aws-sdk/{fetch-http-handler,hash-blob-browser}"
lerna info filter [ '@aws-sdk/{fetch-http-handler,hash-blob-browser}' ]
lerna ERR! EFILTER No packages remain after filtering [ '@aws-sdk/{fetch-http-handler,hash-blob-browser}' ]

Checklist

  • [n/a] If the PR is a feature, add integration tests (*.integ.spec.ts).
  • [n/a ] If you wrote E2E tests, are they resilient to concurrent I/O?
  • [n/a] If adding new public functions, did you add the @public tag and enable doc generation on the package?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@smilkuri smilkuri requested a review from a team as a code owner September 2, 2025 20:54

const warn: (warning: string) => void =
options.logger?.constructor?.name === "NoOpLogger" || !options.logger ? console.warn : options.logger.warn;
options.logger?.constructor?.name === "NoOpLogger" || !options.logger
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
options.logger?.constructor?.name === "NoOpLogger" || !options.logger
options.logger?.constructor?.name === "NoOpLogger" || !options.logger?.warn

our types assume when logger exists, logger.warn exists, but let's be safe here. Some users have passed incomplete loggers in the past.

Copy link
Contributor

@kuhe kuhe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also update packages/credential-provider-node/src/defaultProvider.ts

@smilkuri smilkuri merged commit b5ca7c4 into main Sep 3, 2025
6 checks passed
@kuhe kuhe deleted the fix-logger-binding branch September 5, 2025 14:42
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 Sep 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants