-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix: allow to omit S3 region when endpoint is given #11386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThe Changes
Sequence Diagram(s)No sequence diagram generated as the change is limited to a type definition update. Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@DarkPhoenix2704 would be nice if you could have a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (2)
packages/nocodb/src/plugins/s3/S3.ts (2)
48-63
: 🛠️ Refactor suggestionPotential issue when both region and endpoint are omitted
While making the region optional is correct, there's no explicit validation to ensure that either a region or an endpoint is provided. If both are missing, the initialization could still proceed with incomplete configuration.
Consider adding validation to prevent errors when both region and endpoint are missing:
public async init(): Promise<any> { const s3Options: S3ClientConfig = { region: this.input.region, forcePathStyle: this.input.force_path_style ?? false, }; + if (!this.input.region && !this.input.endpoint) { + throw new Error('Either region or endpoint must be provided for S3 configuration'); + } if (this.input.access_key && this.input.access_secret) { s3Options.credentials = { accessKeyId: this.input.access_key, secretAccessKey: this.input.access_secret, }; } if (this.input.endpoint) { s3Options.endpoint = this.input.endpoint; }
77-87
:⚠️ Potential issuePotential runtime error in URL formation when region is missing
If the region is omitted and no endpoint is provided, the URL construction on line 80 would result in an invalid URL like
s3.undefined.amazonaws.com
.Add a check to handle cases where region might be undefined:
if (data) { const endpoint = this.input.endpoint ? new URL(this.input.endpoint).host - : `s3.${this.input.region}.amazonaws.com`; + : this.input.region + ? `s3.${this.input.region}.amazonaws.com` + : throw new Error('Either region or endpoint must be provided for S3 URL construction'); if (this.input.force_path_style) { return `https://${endpoint}/${this.input.bucket}/${uploadParams.Key}`; } return `https://${this.input.bucket}.${endpoint}/${uploadParams.Key}`;
🧹 Nitpick comments (1)
packages/nocodb/src/plugins/s3/S3.ts (1)
8-16
: Consider enhancing the interface documentationSince this change modifies the contract of the S3Input interface, it would be helpful to add some JSDoc comments to clarify the relationship between region and endpoint.
interface S3Input { bucket: string; + /** + * S3 region. Optional if endpoint is provided. + */ region?: string; access_key?: string; access_secret?: string; + /** + * Custom endpoint URL. If provided, region becomes optional. + */ endpoint?: string; acl?: string; force_path_style?: boolean; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
packages/nocodb/src/plugins/s3/S3.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: pre-build-for-playwright / playwright
- GitHub Check: unit-tests-pg
- GitHub Check: unit-tests
🔇 Additional comments (1)
packages/nocodb/src/plugins/s3/S3.ts (1)
10-10
: Making the region parameter optional is appropriateThis change aligns with the PR objective to allow omitting the S3 region when an endpoint is provided. Making the region property optional in the interface is the correct approach.
Thank you for your contribution |
Change Summary
Follow-up to #9053.
Change type
Test/ Verification
Provide summary of changes.
Additional information / screenshots (optional)
Anything for maintainers to be made aware of