Skip to content

Bug fix: Do not call CheckHealth when authenticating with API keys#232

Merged
Shivs11 merged 3 commits intomainfrom
ss/fix-api-issue
Mar 20, 2026
Merged

Bug fix: Do not call CheckHealth when authenticating with API keys#232
Shivs11 merged 3 commits intomainfrom
ss/fix-api-issue

Conversation

@Shivs11
Copy link
Copy Markdown
Member

@Shivs11 Shivs11 commented Mar 20, 2026

What was changed

  • WISOTT
  • Note: This bug fix was an unfortunate regression that was introduced with this. This intends on fixing that.

Why?

  • Bug fix!

Checklist

  1. Closes

  2. How was this tested:

  1. Any docs updates needed?

Copy link
Copy Markdown
Collaborator

@carlydf carlydf left a comment

Choose a reason for hiding this comment

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

what you did is good. imo also fine to just do Dial and no CheckHealth in all cases

@Shivs11 Shivs11 marked this pull request as ready for review March 20, 2026 19:04
@Shivs11 Shivs11 requested review from a team and jlegrone as code owners March 20, 2026 19:04
@Shivs11 Shivs11 merged commit 0e04305 into main Mar 20, 2026
16 checks passed
@Shivs11 Shivs11 deleted the ss/fix-api-issue branch March 20, 2026 19:16
Shivs11 added a commit that referenced this pull request Mar 20, 2026
)

<!--- Note to EXTERNAL Contributors -->
<!-- Thanks for opening a PR! 
If it is a significant code change, please **make sure there is an open
issue** for this.
We work best with you when we have accepted the idea first before you
code. -->

<!--- For ALL Contributors 👇 -->

## What was changed
- WISOTT
- Note: This bug fix was an unfortunate regression that was introduced
with
[this](#203).
This intends on fixing that.

## Why?
- Bug fix!

## Checklist
<!--- add/delete as needed --->

1. Closes <!-- add issue number here -->

2. How was this tested:
<!--- Please describe how you tested your changes/how we can test them
-->

3. Any docs updates needed?
<!--- update README if applicable
      or point out where to update docs.temporal.io -->
carlydf added a commit that referenced this pull request Mar 21, 2026
Introduces clientpool_test.go with 8 tests that directly cover the two
regression patterns that slipped through CI:

- TestFetchMTLS_CACertAppendsToSystemPool: regression test for PR #227
  (empty cert pool replacing system CAs). Injects a fake system pool and
  verifies both injected system CAs and the custom ca.crt are trusted.

- TestDialAndUpsert_APIKeySkipsCheckHealth: regression test for PR #232
  (CheckHealth called unconditionally). Verifies CheckHealth is not
  invoked when AuthModeAPIKey is used.

To make both code paths injectable in tests, ClientPool gains two new
function fields (dialFn, systemCertPoolFn) wired to sdkclient.Dial and
x509.SystemCertPool by default — no behavior change in production.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
carlydf added a commit that referenced this pull request Mar 21, 2026
Introduces clientpool_test.go with 8 tests that directly cover the two
regression patterns that slipped through CI:

- TestFetchMTLS_CACertAppendsToSystemPool: regression test for PR #227
  (empty cert pool replacing system CAs). Injects a fake system pool and
  verifies both injected system CAs and the custom ca.crt are trusted.

- TestDialAndUpsert_APIKeySkipsCheckHealth: regression test for PR #232
  (CheckHealth called unconditionally). Verifies CheckHealth is not
  invoked when AuthModeAPIKey is used.

To make both code paths injectable in tests, ClientPool gains two new
function fields (dialFn, systemCertPoolFn) wired to sdkclient.Dial and
x509.SystemCertPool by default — no behavior change in production.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
carlydf added a commit that referenced this pull request Mar 23, 2026
## Summary

- Adds `clientpool_test.go` with 8 unit tests covering the auth code
paths that had no test coverage
- Two tests are explicit regression guards for the bugs fixed in #227
and #232
- Makes `dialFn` and `systemCertPoolFn` injectable on `ClientPool` (no
behavior change in production) to enable testing without network I/O or
OS trust store dependencies

## Regression tests

**`TestFetchMTLS_CACertAppendsToSystemPool`** — guards against the PR
#212 bug (fixed in #227): `fetchClientUsingMTLSSecret` used
`x509.NewCertPool()` (empty) instead of `x509.SystemCertPool()`,
silently dropping system root CAs and breaking Temporal Cloud
connections. The test injects a fake system pool and verifies both the
injected system CAs and the custom `ca.crt` are present in the returned
pool. This test fails if the fix is reverted.

**`TestDialAndUpsert_APIKeySkipsCheckHealth`** — guards against the PR
#203 bug (fixed in #232): `DialAndUpsertClient` called `CheckHealth`
unconditionally, which fails on Temporal Cloud with namespace-scoped API
keys. The test uses an injected mock client and asserts `CheckHealth` is
never called for `AuthModeAPIKey`. This test fails if the fix is
reverted.

## Test plan

- [x] `go test ./internal/controller/clientpool/... -v` — all 8 tests
pass
- [x] `go build ./...` — no compilation errors
- [x] Manually revert the PR #227 fix →
`TestFetchMTLS_CACertAppendsToSystemPool` fails
- [x] Manually revert the PR #232 fix →
`TestDialAndUpsert_APIKeySkipsCheckHealth` fails

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants