Skip to content

DEP-261: update object storage service to normalize URLs to keys - #2842

Merged
NatSquared merged 5 commits into
mainfrom
DEP-261-object-storage-normalize-urls
Apr 30, 2026
Merged

DEP-261: update object storage service to normalize URLs to keys#2842
NatSquared merged 5 commits into
mainfrom
DEP-261-object-storage-normalize-urls

Conversation

@NatSquared

Copy link
Copy Markdown
Collaborator

Issue #: 🎟️ DEP-261

Description of changes:

  • Feature Updated all S3 uploaded objects to dynamically generate document URLs from the bucket and object key, rather than storing the full URL in the database.
    • Updated the API to generate S3 object URLs on-the-fly using the bucket name and object key, rather than storing the full URL in the database. This allows for more flexibility in changing storage configurations in the future without needing to update existing database records.
    • Updated relevant API endpoints to reflect this change, including those for retrieving engagement details, survey details, and any other endpoints that return data with S3 object references.
    • Added basic unit tests for S3 service and URL generation test to ensure that URLs are generated correctly.

User Guide update ticket (if applicable):

    • Yes, a user guide update ticket has been created. (Link to ticket)
    • No, a user guide update ticket is not required.

Common component changes:

    • Yes, I have updated CONTRIBUTING.md and the docblocks to document any changes to the common components.
    • No, there are no changes to the common components.

@codecov-commenter

codecov-commenter commented Apr 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.96%. Comparing base (b568692) to head (a705720).

Files with missing lines Patch % Lines
api/src/api/schemas/widget_documents.py 61.53% 5 Missing ⚠️
api/src/api/services/widget_image_service.py 28.57% 5 Missing ⚠️
api/src/api/schemas/tenant.py 86.66% 2 Missing ⚠️
api/src/api/services/widget_documents_service.py 81.81% 2 Missing ⚠️
api/src/api/services/object_storage_service.py 94.11% 1 Missing ⚠️
api/src/api/services/tenant_service.py 90.00% 1 Missing ⚠️
...s/engagement/form/EngagementWidgets/Image/Form.tsx 0.00% 1 Missing ⚠️
web/src/components/tenantManagement/TenantForm.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2842      +/-   ##
==========================================
+ Coverage   74.92%   74.96%   +0.04%     
==========================================
  Files         517      517              
  Lines       19853    19932      +79     
  Branches     1612     1715     +103     
==========================================
+ Hits        14874    14942      +68     
- Misses       4971     4981      +10     
- Partials        8        9       +1     
Flag Coverage Δ
api 85.04% <81.81%> (+<0.01%) ⬆️
web 63.40% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
api/src/api/schemas/widget_image.py 100.00% <100.00%> (ø)
...m/EngagementWidgets/Documents/UploadFileDrawer.tsx 30.48% <ø> (ø)
api/src/api/services/object_storage_service.py 70.21% <94.11%> (+20.21%) ⬆️
api/src/api/services/tenant_service.py 94.52% <90.00%> (-0.87%) ⬇️
...s/engagement/form/EngagementWidgets/Image/Form.tsx 22.68% <0.00%> (ø)
web/src/components/tenantManagement/TenantForm.tsx 78.31% <0.00%> (ø)
api/src/api/schemas/tenant.py 92.59% <86.66%> (-7.41%) ⬇️
api/src/api/services/widget_documents_service.py 93.33% <81.81%> (-1.46%) ⬇️
api/src/api/schemas/widget_documents.py 75.00% <61.53%> (-25.00%) ⬇️
api/src/api/services/widget_image_service.py 36.58% <28.57%> (+0.47%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jareth-whitney jareth-whitney left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's a fancy way to make links - looks good! Just review what you're passing into get_url() on line 96 of test_object_storage_service.py.

service = ObjectStorageService()

assert service.get_url('') == ''
assert service.get_url(None) == ''

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like SonarCloud doesn't like the type that you're passing to get_url here.

try {
const savedDocumentDetails = await saveObject(bannerImage, { filename: bannerImage.name });
return savedDocumentDetails?.filepath || '';
return savedDocumentDetails?.uniquefilename || '';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I prefer this

@sonarqubecloud

Copy link
Copy Markdown

@NatSquared
NatSquared merged commit 09f6c23 into main Apr 30, 2026
16 checks passed
@NatSquared
NatSquared deleted the DEP-261-object-storage-normalize-urls branch April 30, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants