Make the MSK IAM token provider example survive Config deepcopy and return seconds #1386
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.60) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.60 · 232 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.326
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.060
Real PR Conversation Timeline
1 comments
"Review active on #1386"
general
weight: 0.35
muralibasani
What
Fixes
examples/msk_iam_token_provider.pyso it works when used exactly as its docstring says, and documents the two protocol constraints it was violating.1. Lazy signer import. The example cached the
aws_msk_iam_sasl_signermodule onself.Config.model_post_initinstantiates the provider and keeps it in a private attribute, anddependency_injectordeep-copies theConfigwhile wiring containers, so startup failed with:The signer is now imported inside
token_with_expiry; the instance holds only the optional region string.2. Expiry in seconds.
token_with_expiryis passed straight to librdkafka asoauth_cb, which reads the expiry in seconds. The MSK signer returns milliseconds. Passing them through made librdkafka treat the token as expiring in the year ~58000, so it never refreshed and the broker rejected the stale token about 15 minutes after startup. The example now divides by 1000.3. Region from env first.
AWS_REGION/AWS_DEFAULT_REGIONare checked before importing boto3 for the session default.The module docstring and
examples/README.rstnow state both constraints: the expiry unit, and that provider instances must stay picklable.Tests
tests/unit/test_msk_iam_token_provider_example.pyloads the example by path (no new test dependency; the AWS signer is stubbed insys.modules) and checks: the instance deep-copies, it can be constructed without the signer installed, the returned expiry is in seconds, and the region falls back to the env. Against the previous example the deepcopy test fails withcannot pickle 'module' objectand the unit test with1800000000000 == 1800000000.