You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2023-04-04] Attachments (w/o preview: mp4, docx etc) use Prod domain in case of download #16327
Prod side: upload attachment without preview docx. mp4 etc to the chat
On staging click on the download button
check from which domain the file is download
Expected Result:
All attachment URLs to be resolved relative to current environment
Actual Result:
If file without preview like docx or mp4 sent from the Prod and it will be downloaded from the Staging via www.expensify.com
domain instead of staging.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Android / native
Android / Chrome
iOS / native
iOS / Safari
MacOS / Chrome / Safari
MacOS / Desktop
Version Number: 1.2.87.0
Reproducible in staging?: Yes
Reproducible in production?: yes
If this was caught during regression testing, add the test name, ID and link from TestRail:
Please re-state the problem that we are trying to solve in this issue.
Downloading attachments with no preview is not respecting the API in use - being on staging would load an attachment from the prod URL (when the attachment was originally uploaded on prod)
What is the root cause of that problem?
When we upload an attachment the backend saves the address including the host where the attachment was originally uploaded from (uploading an attachment from prod, saves the prod address to the attachment)
What changes do you think we should make in order to solve the problem?
(backend) Don't save the host which uploaded the attachment, only the path for the attachment relative to API root
❌ www.expensify.com/chat-attachments/{path}
✔️ /chat-attachments/{path}
(backend) Migrate existing attachment URLs - remove the host portion from them
(app) App logic can prefix attachments with the current API
What alternative solutions did you explore? (Optional)
Because of Old Dot, a migration would probably not be possible ATM (migration would break Old Dot)
We have reusable logic that remmaps hosts to the current environment
The ideal solution would be if we don't have to do anything with the URL at all
If the API and the website were hosted from the same origin a path like /chat-attachments/{path} would be resolved from {origin}/chat-attachments/{path}
The next best thing is, manually prefixing with the current api {API_ROOT}/chat-attachments/{path}
And 3rd, the only thing possible ATM is, replacing the origin dynamically {PROD_OR_STAGING/chat-attachments/{path} -> {API_ROOT}/chat-attachments/{path}
changed the title [-]Desktop - Attachments (w/o preview: mp4, docx etc) use Prod domain in case of download[/-][+]Attachments (w/o preview: mp4, docx etc) use Prod domain in case of download[/+]on Mar 21, 2023
changed the title [-]Attachments (w/o preview: mp4, docx etc) use Prod domain in case of download[/-][+][HOLD for payment 2023-04-04] Attachments (w/o preview: mp4, docx etc) use Prod domain in case of download[/+]on Apr 4, 2023
Activity
MelvinBot commentedon Mar 20, 2023
Triggered auto assignment to @maddylewis (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.MelvinBot commentedon Mar 20, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)mountiny commentedon Mar 21, 2023
@kidroca Can you have a look at this one? This came from testing your PR, thanks!
kidroca commentedon Mar 21, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Downloading attachments with no preview is not respecting the API in use - being on staging would load an attachment from the prod URL (when the attachment was originally uploaded on prod)
What is the root cause of that problem?
When we upload an attachment the backend saves the address including the host where the attachment was originally uploaded from (uploading an attachment from prod, saves the prod address to the attachment)
What changes do you think we should make in order to solve the problem?
www.expensify.com/chat-attachments/{path}/chat-attachments/{path}What alternative solutions did you explore? (Optional)
Because of Old Dot, a migration would probably not be possible ATM (migration would break Old Dot)
We have reusable logic that remmaps hosts to the current environment
App/src/libs/tryResolveUrlFromApiRoot.js
Lines 17 to 30 in 44f9871
We can use it in order to substitute the API portion of the address with the API we're currently using, by updating the code here
App/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js
Line 27 in 743ae89
With something like
The ideal solution would be if we don't have to do anything with the URL at all
If the API and the website were hosted from the same origin a path like
/chat-attachments/{path}would be resolved from{origin}/chat-attachments/{path}The next best thing is, manually prefixing with the current api
{API_ROOT}/chat-attachments/{path}And 3rd, the only thing possible ATM is, replacing the origin dynamically
{PROD_OR_STAGING/chat-attachments/{path}->{API_ROOT}/chat-attachments/{path}mountiny commentedon Mar 21, 2023
Lets fix this @kidroca feel free to create a PR
kidroca commentedon Mar 21, 2023
BTW the issue is not tied to Desktop - it affects all platforms, though I don't think QA would be able to detect this on mobile
[-]Desktop - Attachments (w/o preview: mp4, docx etc) use Prod domain in case of download[/-][+]Attachments (w/o preview: mp4, docx etc) use Prod domain in case of download[/+]mountiny commentedon Mar 21, 2023
Makes sense, updated the title and issue body
5 remaining items
kidroca commentedon Mar 24, 2023
Created a PR, ready for review, I'll be able to add test steps and screens on Monday
kidroca commentedon Mar 27, 2023
PR updated and ready for review
kidroca commentedon Apr 4, 2023
✅ PR was merged last week
parasharrajat commentedon Apr 4, 2023
@maddylewis Please move this back to Weekly and assign me as C+ as I reviewed the PR. Also, the header did not update to reflect payments, etc.
Thanks.
[-]Attachments (w/o preview: mp4, docx etc) use Prod domain in case of download[/-][+][HOLD for payment 2023-04-04] Attachments (w/o preview: mp4, docx etc) use Prod domain in case of download[/+]mountiny commentedon Apr 4, 2023
@maddylewis could you please pay @parasharrajat $1000 for his work on this issue, thank you very much!
maddylewis commentedon Apr 5, 2023
on it!
maddylewis commentedon Apr 5, 2023
paid!
parasharrajat commentedon Apr 5, 2023
Question: Is this Internal or external @mountiny? Or this was handled as regression.
If this is external, is it valid for a bonus?
mountiny commentedon Apr 6, 2023
I would say this was handled as a regression/ oversight since we implemented these changes before and this hsould have been done in the original PR
Are we good to close?