enhancement: add configurable S3 storage prefix#356
Conversation
📝 WalkthroughWalkthroughThis PR adds an optional ChangesS3 Prefix Support
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant StorageS3Form
participant S3ChannelConfigSchema
participant S3Storage as "s3.ts operations"
User->>StorageS3Form: Enter prefix value
StorageS3Form->>S3ChannelConfigSchema: Validate config (with prefix)
S3ChannelConfigSchema-->>StorageS3Form: Validated config
StorageS3Form->>S3Storage: Save config
S3Storage->>S3Storage: buildKey(config, path)
S3Storage-->>S3Storage: prefix/normalizedPath or normalizedPath
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Hi @Antoninj , Could you describe a bit more you use case ? Tests are in : https://github.com/Portabase/e2e-tests you can are test to it directly This e2e tests are called in PR, like a component |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/features/channel/components/storages/s3.ts`:
- Around line 34-39: Add unit tests for buildKey to cover the centralized S3 key
normalization logic used by upload/get/delete/ping/copy. Focus on edge cases
around S3Config.prefix and path handling: empty or whitespace-only prefix,
prefix containing only slashes, path values with leading/trailing slashes, and
paths with multiple internal slashes. Use buildKey and S3Config as the main
symbols to locate the behavior and verify the returned key strings for each
case.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: fbc8effb-dc47-40c1-bf7e-80df479d9bde
📒 Files selected for processing (3)
src/features/channel/components/storages/s3.form.tsxsrc/features/channel/components/storages/s3.schema.tssrc/features/channel/components/storages/s3.ts
📜 Review details
🔇 Additional comments (3)
src/features/channel/components/storages/s3.schema.ts (1)
9-9: LGTM!src/features/channel/components/storages/s3.form.tsx (1)
87-99: LGTM!src/features/channel/components/storages/s3.ts (1)
34-39: 🗄️ Data Integrity & IntegrationNo backward-compatibility issue.
prefixis opt-in; existing S3 configs keep using the raw object path, so there’s no key-namespace migration here.> Likely an incorrect or invalid review comment.
|
-> Could you describe a bit more you use case ? The use case is the following: I use the same S3 bucket for multiple backups (not only portabase ones). Currently, portabase hardcodes the prefix to
thanks I'll take a look and see if adding an E2E test makes sense for my changes. But in any case, I'd need to get those changes in first |
|
Added E2E coverage in Portabase/e2e-tests#11. It fills the new S3 Prefix field for the existing S3/R2 storage channel flow and verifies the value persists when reopening the channel. I left it as a draft because it depends on this PR introducing the Prefix field. |
|
Hi @Antoninj, I now understand your use case. This PR will not work as-is because uploads are handled partly on the dashboard side at some point, but mainly by the agent when dispatching backup files to storage after the backup is completed. What I suggest is adding an environment variable on the dashboard side, for example I think this would be more generic and would apply consistently across the whole ecosystem. Could you open an issue so we can continue the discussion there? I can work on it ASAP, but if you want, you can also start implementing the dashboard-side part, and I can finish the agent-side integration. Regards, |
|
Sounds good I'll do that thanks |
Feel free to ask if you have any questions. I’d be happy to help. |
|
Thanks. I won't have time to iterate on this before next week end though. |
No problem, ping me when you have time |
Summary
Note: I'm surprised there isn't any test suite in this project.
Summary by CodeRabbit
New Features
Bug Fixes