fix(credentials/aws): resolve Self account (empty role ARN) to ambient creds (closes #605) - #612
Conversation
…t creds (closes #605) When an account is registered with auth_mode=role_arn and aws_role_arn="" (the "Self" shape), the collector already treats it as an ambient-creds case (collectAWSForAccount early-returns to ambient when AWSRoleARN==""). The executor's resolver path through resolveRoleARNProvider rejected the same shape with a hard error, causing every approve action against the CUDly host account to fail. Fix: pass AWSResolveOptions.AmbientProvider through the role_arn switch case; resolveRoleARNProvider returns it directly when AWSRoleARN is empty, falling back to a descriptive error when ambient is nil. Thread ambient creds (awsCfg.Credentials) through purchase.Manager and the commitment-opts closure in server/app.go so the two callers that previously used the back- compat wrapper now supply a valid ambient provider. Tests: positive (Self+ambient returns ambient, no error), negative (Self+nil ambient returns descriptive error), regression (existing role_arn-with-ARN path unchanged, all 83 credential tests pass).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR enables AWS credential resolution for "Self" accounts—those configured with role_arn auth mode but no role ARN—by threading an injected ambient AWS credentials provider through the resolver, purchase manager, and server configuration. The resolver now returns the ambient provider when the role ARN is empty and available, or returns a descriptive error when it is not. ChangesSelf-Account Ambient Credential Resolution
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
resolveRoleARNProviderreturned a hard error whenAWSRoleARN==""(the "Self" account shape), while the scheduler'scollectAWSForAccounttreated the same shape as the ambient-creds case, causing every approve action against the CUDly host account to fail.opts.AmbientProvider(newAWSResolveOptionsfield) whenAWSRoleARNis empty; falls back to a descriptive error when ambient is nil.awsCfg.CredentialsasAmbientAWSCredsthroughpurchase.Manager(new field) and the commitment-opts closure inserver/app.goso both callers supply a valid ambient provider.Test plan
TestResolveAWSCredentialProvider_SelfAccount_WithAmbient- Self shape + ambient returns ambient, no errorTestResolveAWSCredentialProvider_SelfAccount_NilAmbient- Self shape + nil ambient returns descriptive errorTestResolveAWSCredentialProvider_RoleARN_NoARN_NilAmbient- back-compat wrapper (nil ambient) returns descriptive errorrole_arn-with-ARN path regression: all 83 credential tests passgo build ./...)Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Tests