Skip to content

Convert createClient/shutdown failures to Unhealthy in DynamoDB check - #234

Open
sksamuel wants to merge 1 commit into
mainfrom
fix/dynamodb-catch-create-client-errors
Open

Convert createClient/shutdown failures to Unhealthy in DynamoDB check#234
sksamuel wants to merge 1 commit into
mainfrom
fix/dynamodb-catch-create-client-errors

Conversation

@sksamuel

Copy link
Copy Markdown
Owner

Summary

  • `createClient()` is user-supplied; AWS region/credential resolution can throw synchronously from `builder().build()`. That exception escaped `runInterruptible` and `check()`, so the registry saw a raw exception instead of an Unhealthy result.
  • `shutdown()` ran unguarded — a throw there masked the original check failure.

Wrap the whole `runInterruptible` in `runCatching` and guard the shutdown.

Test plan

  • Existing tests pass
  • Misconfigured AWS region: check produces Unhealthy("Could not connect to DynamoDB")

🤖 Generated with Claude Code

Two problems with the old wiring:

1. `createClient()` is a user-supplied lambda invoked inside
   `runInterruptible`. If it threw synchronously (typical: AWS region or
   credential resolution failure on `AmazonDynamoDBClient.builder().build()`),
   the exception propagated through `runInterruptible` and out of
   `check()` — the `.fold` on `Result` was never reached. The registry
   sees an exception rather than the expected Unhealthy.

2. The inner `use` extension called `shutdown()` unconditionally. If
   `shutdown()` itself threw (rare but possible during AWS SDK
   teardown), the original check failure was masked.

Wrap the whole runInterruptible in runCatching and guard the shutdown
call so the original cause always reaches the operator.

Co-Authored-By: Claude Opus 4.7 (1M context) <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.

1 participant