Skip to content

fix: avoid panics on unsupported logger types#290

Open
happysnaker wants to merge 1 commit into
hashicorp:mainfrom
happysnaker:fix-invalid-logger-no-panic
Open

fix: avoid panics on unsupported logger types#290
happysnaker wants to merge 1 commit into
hashicorp:mainfrom
happysnaker:fix-invalid-logger-no-panic

Conversation

@happysnaker

Copy link
Copy Markdown

Summary

  • stop treating unsupported Client.Logger values as a runtime panic
  • fall back to no-op internal logging when the logger does not implement Logger or LeveledLogger
  • add regression coverage showing requests and log hooks still complete without crashing

Why

The current Client.logger() path panics during request execution when Client.Logger is set to an unsupported type. That turns a configuration mistake into a production crash.

This patch keeps the existing supported logger behavior unchanged, but treats unsupported logger values the same way as no logger for internal logging paths. Requests still complete, hooks still run, and applications no longer crash at runtime because of an invalid logger assignment.

Closes #243.

@happysnaker happysnaker requested a review from a team as a code owner June 30, 2026 14:51
@hashicorp-cla-app

hashicorp-cla-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@happysnaker

Copy link
Copy Markdown
Author

This should be ready for review on my side.

I have already signed the HashiCorp CLA previously, but the license/cla check is still showing as pending right after PR creation, so I'm waiting for that status to refresh.

Change summary:

  • stop treating unsupported Client.Logger values as a runtime panic
  • fall back to no-op internal logging for unsupported logger types
  • add regression coverage showing requests and log hooks still complete without crashing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using custom logger type causes panic at runtime

1 participant