Conversation
📝 WalkthroughSummary by CodeRabbitRelease Notes
WalkthroughThis change enhances AWS configuration flexibility for envase integration by converting Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/app/aws-config/src/envaseAwsConfig.ts (1)
110-133: Consider guarding against empty string path.The implementation correctly handles the
pathoption, but an empty string""is truthy in the conditional check on line 123, yet accessingraw[""]would be semantically incorrect usage. Consider adding validation or documenting this edge case.🛡️ Optional: Add guard for empty string path
function createAwsComputed<TPath extends string | undefined>( path?: TPath, ): EnvaseAwsConfigFragments<TPath>['computed'] { const resolveCredentials = (awsRaw: { accessKeyId?: string secretAccessKey?: string }): AwsCredentialIdentity | Provider<AwsCredentialIdentity> => { if (awsRaw.accessKeyId && awsRaw.secretAccessKey) { return { accessKeyId: awsRaw.accessKeyId, secretAccessKey: awsRaw.secretAccessKey } } return createCredentialChain(fromTokenFile(), fromInstanceMetadata(), fromEnv(), fromIni()) } - if (path) { + if (path && path.length > 0) { return { // biome-ignore lint/suspicious/noExplicitAny: raw config shape depends on consumer's schema credentials: (raw: any) => resolveCredentials(raw[path]), } as EnvaseAwsConfigFragments<TPath>['computed'] } return { credentials: resolveCredentials, } as EnvaseAwsConfigFragments<TPath>['computed'] }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/app/aws-config/src/envaseAwsConfig.ts` around lines 110 - 133, The createAwsComputed function currently treats any truthy path (including empty string) as a valid key and calls credentials: (raw: any) => resolveCredentials(raw[path]); add a guard to detect and reject empty-string paths: validate the path parameter (e.g., if (path === '' || path == null) treat it as no-path) before the conditional that returns the object with credentials: (raw: any) => resolveCredentials(raw[path]); and update the branch that returns credentials: resolveCredentials accordingly so resolveCredentials is never called with raw[''] — either throw a clear error for empty string paths or fall back to the no-path behavior; reference createAwsComputed, path, resolveCredentials, and the credentials property to locate the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/app/aws-config/src/envaseAwsConfig.ts`:
- Around line 110-133: The createAwsComputed function currently treats any
truthy path (including empty string) as a valid key and calls credentials: (raw:
any) => resolveCredentials(raw[path]); add a guard to detect and reject
empty-string paths: validate the path parameter (e.g., if (path === '' || path
== null) treat it as no-path) before the conditional that returns the object
with credentials: (raw: any) => resolveCredentials(raw[path]); and update the
branch that returns credentials: resolveCredentials accordingly so
resolveCredentials is never called with raw[''] — either throw a clear error for
empty string paths or fall back to the no-path behavior; reference
createAwsComputed, path, resolveCredentials, and the credentials property to
locate the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: lokalise/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 640e400b-abbb-4f9c-baa7-2199fecfa6f4
📒 Files selected for processing (4)
packages/app/aws-config/README.mdpackages/app/aws-config/src/envaseAwsConfig.spec.tspackages/app/aws-config/src/envaseAwsConfig.tspackages/app/aws-config/src/index.ts
Changes
Summary
{ path }parameter togetEnvaseAwsConfig()that generates computed resolvers scoped to thespecified config key (e.g.,
fullParsedConfig.aws)Problem
When consumers nest AWS config under a key like
aws, envase passes the full parsed config to computed resolvers.Since the
credentialsresolver expects{ accessKeyId, secretAccessKey }at the root, consumers had to write amanual wrapper:
Solution
getEnvaseAwsConfig({ path: 'aws' }) generates resolvers that read from fullParsedConfig.aws automatically:
Omitting path preserves the existing flat spread behavior.
Checklist
major,minor,patchorskip-releaseAI Assistance Tracking
We're running a metric to understand where AI assists our engineering work. Please select exactly one of the options below:
Mark "Yes" if AI helped in any part of this work, for example: generating code, refactoring, debugging support,
explaining something, reviewing an idea, or suggesting an approach.