Skip to content
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

[PAID] [$1000] Setting - Console error appears and avatar is broken when uploading a photo to the profile #16354

Closed
6 tasks done
kbecciv opened this issue Mar 21, 2023 · 37 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Mar 21, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Access staging.new.expensify.com
  2. Sign into a valid account
  3. Open your JS console
  4. Go to Settings > Profile > Click on profile photo
  5. Click on Remove photo
  6. Click on the profile photo again > Click on Upload photo
  7. Select photo and see JS console errors,
  8. Close profile window and see profile photo isn't updated at the top left,

Image:

Sombrero cat (1)

Expected Result:

The profile photo should be display and there should be no error in the console

Actual Result:

Console error appears and avatar is broken when uploading a photo to the profile

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.88.0

Reproducible in staging?: Yes

Reproducible in production?: NO

If this was caught during regression testing, add the test name, ID and link from TestRail:

Email or phone of affected tester (no customers):

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

Recording.2347.mp4

image (25)

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team

Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~014508d42c3166d105
  • Upwork Job ID: 1638299901026033664
  • Last Price Increase: 2023-03-21
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 21, 2023
@MelvinBot
Copy link

Triggered auto assignment to @strepanier03 (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@MelvinBot
Copy link

MelvinBot commented Mar 21, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@strepanier03
Copy link
Contributor

I updated the steps to recreate to make them a little more clear. I was able to recreate this though so sending on.

2023-03-21_14-54-59

@strepanier03 strepanier03 added the External Added to denote the issue can be worked on by a contributor label Mar 21, 2023
@melvin-bot melvin-bot bot changed the title Setting - Console error appears and avatar is broken when uploading a photo to the profile [$1000] Setting - Console error appears and avatar is broken when uploading a photo to the profile Mar 21, 2023
@MelvinBot
Copy link

Job added to Upwork: https://www.upwork.com/jobs/~014508d42c3166d105

@MelvinBot
Copy link

Current assignee @strepanier03 is eligible for the External assigner, not assigning anyone new.

@MelvinBot
Copy link

Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt (External)

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 21, 2023
@MelvinBot
Copy link

Triggered auto assignment to @yuwenmemon (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@dayyad
Copy link

dayyad commented Mar 22, 2023

Proposal

Problem: Users are unable to successfully upload a profile photo in the React project, resulting in JavaScript console errors and a failure to update the displayed profile photo.

Root Cause: The root cause of this issue might be related to CORS configuration, improper handling of Blob URLs, or incorrect state updates in the application.

Proposed Solution:

CORS issues: Verify if the server is configured correctly to add the necessary CORS headers, allowing cross-origin access. Implement CORS middleware in the server-side code if needed.

Blob URL handling: Ensure proper creation and revoking of Blob URLs by utilizing the URL.createObjectURL() and URL.revokeObjectURL() methods in the code.

State updates: Confirm that the state is being correctly updated when the profile photo is uploaded, reflecting the new photo URL and displaying the photo as expected in the application.

Alternative Solutions Explored: N/A

Next Steps: Once the proposal is reviewed and approved by the Expensify team, I will proceed to implement the changes and create a pull request for review.

@MelvinBot
Copy link

📣 @dayyad! 📣

Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  2. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.

Screen Shot 2022-11-16 at 4 42 54 PM

Format:

Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@dayyad
Copy link

dayyad commented Mar 22, 2023

Contributor details
Your Expensify account email: jonahease@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/jonahe

@MelvinBot
Copy link

⚠️ Missing/invalid email or upwork profile link. Please make sure you add both your Expensify email and Upwork profile link in the format specified.

@dayyad
Copy link

dayyad commented Mar 22, 2023

Contributor details
Your Expensify account email: jonahease@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01e2b4d8accc1f40d3

@MelvinBot
Copy link

⚠️ Missing/invalid email or upwork profile link. Please make sure you add both your Expensify email and Upwork profile link in the format specified.

@dayyad
Copy link

dayyad commented Mar 22, 2023

Contributor details
Your Expensify account email: jonahease@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01e2b4d8accc1f40d3

@MelvinBot
Copy link

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@fedirjh
Copy link
Contributor

fedirjh commented Mar 22, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Console error appears and avatar is broken when uploading a photo to the profile

What is the root cause of that problem?

This is a regression from #15680. When we upload a new avatar and it is being uploaded to the server, the source of the profile avatar is set as a blob source. However, with PR #15680, we attempt to append _128 to the end of the source for the thumbnail avatar in the LHN. here

return `${source.substring(0, lastPeriodIndex)}_128${source.substring(lastPeriodIndex)}`;

And we use it here
source={ReportUtils.getSmallSizeAvatar(props.source)}

So when we try to append _128 to source we get this issue

Screenshot 2023-03-22 at 2 41 47 AM

Screenshot 2023-03-22 at 2 42 06 AM

Screenshot 2023-03-22 at 2 42 39 AM

What changes do you think we should make in order to solve the problem?

We can check if source is blob and skip adding _128 to url inside getSmallSizeAvatar

    const regex = /^blob:(.*\/)?[a-f\d-]{36}$/i;

    if (regex.test(source)) {
        return source;
    }

I think there is also a small issue here , there is signature mismatch here : getSmallSizeAvatar require two parameters

source={ReportUtils.getSmallSizeAvatar(props.source)}

And I think the changes should occur here

<AvatarWithIndicator
source={ReportUtils.getAvatar(this.props.currentUserPersonalDetails.avatar, this.props.currentUserPersonalDetails.login)}
tooltipText={this.props.translate('common.settings')}
/>

What alternative solutions did you explore? (Optional)

I may tag @Beamanator since he introduced the changes .

@hellohublot
Copy link
Contributor

hellohublot commented Mar 22, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Setting - Console error appears and avatar is broken when uploading a photo to the profile

What is the root cause of that problem?

#15680

We add the picture size param to the url suffix, let cloudfront.net help us process and return the picture of the right size, and display it on the small avatar of LHN. If the picture starts with 'https://xxxx.cloudfront.net/xxx.png', it does work well

But when image is uploading, onyxDB.personalDetails.avatar temporarily saves with the url blob:https://staging.new.expensify.com/XXXX-XXXX, so add _128 in url will cause problems

What changes do you think we should make in order to solve the problem?

In fact, only cloudfront.net can receive such a _128 suffix and handle the image size, so we judge whether this image server is used

+  const imageServerDomainMatch = '^https://\\w+.cloudfront.net'
+  if (!new RegExp(imageServerDomainMatch).test(avatarURL)) {
+       return source;
+  }

Other cases to consider

  • In the case of offline network upload, onyxDB.personalDetails.avatar is always blob:// because no push message is received, so there is no way to always scale this small size
  • If we received file:///var/xxx.png on the native mobile platform
  • There are some _128 in the ReportUtils code, maybe we can refactor to convertImgeUrl(url, size)

What alternative solutions did you explore? (Optional)

Not Yet

@kbecciv
Copy link
Author

kbecciv commented Mar 22, 2023

@strepanier03 This is issue ONLY in stsging, did not use Deploy broker due to PR related.

@s77rt
Copy link
Contributor

s77rt commented Mar 22, 2023

@dayyad Thanks for the proposal. I think your RCA is invalid. You need to pinpoint the exact root cause and not list random potential causes.

@s77rt
Copy link
Contributor

s77rt commented Mar 22, 2023

@fedirjh Thanks for the proposal. Your RCA is correct however the fix is not solid enough as we may encounter the same issue with other links besides those that start with blob:.

@s77rt
Copy link
Contributor

s77rt commented Mar 22, 2023

@hellohublot Thanks for the proposal. Your RCA is correct and the proposed fix looks good to me; I like the idea of relaying on a white list instead of a black list.

🎀 👀 🎀 C+ reviewed

cc @yuwenmemon

@s77rt
Copy link
Contributor

s77rt commented Mar 24, 2023


Regression Test Proposal

  1. Open App
  2. Go to Settings > Profile > Click on profile photo
  3. Click on Remove photo (if a photo is selected already)
  4. Click on the profile photo again then Click on Upload photo
  5. Select a photo and verify no errors appear in the JS console
  6. Close modal and verify profile photo is correctly updated on LHN

@luacmartins
Copy link
Contributor

@yuwenmemon @AndrewGable @marcochavezf is this still a deploy blocker? I'm confused by all the labels on this issue.

@rushatgabhane
Copy link
Member

@luacmartins no, it was fixed in #16441

@melvin-bot melvin-bot bot removed the Overdue label Mar 27, 2023
@s77rt
Copy link
Contributor

s77rt commented Mar 27, 2023

@yuwenmemon Please re-open. This is on hold for payment (and checklist).

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Mar 27, 2023
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2023-03-31] [$1000] Setting - Console error appears and avatar is broken when uploading a photo to the profile [HOLD for payment 2023-04-03] [HOLD for payment 2023-03-31] [$1000] Setting - Console error appears and avatar is broken when uploading a photo to the profile Mar 27, 2023
@MelvinBot
Copy link

MelvinBot commented Mar 27, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.2.89-0 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-04-03. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter - Internal report
  • Contributor that fixed the issue - @hellohublot - $1000 + $500 (speed bonus) = $1500
  • Contributor+ that helped on the issue and/or PR - @s77rt - $1000 + $500 (speed bonus) = $1500

Speed bonus analysis: PR submitted on March 23 - PR merged on March 24 - Eligible

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@MelvinBot
Copy link

MelvinBot commented Mar 27, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

@yuwenmemon yuwenmemon reopened this Mar 27, 2023
@luacmartins luacmartins removed the DeployBlockerCash This issue or pull request should block deployment label Mar 27, 2023
@luacmartins
Copy link
Contributor

Removing the blocker label since this issue was fixed here

@s77rt
Copy link
Contributor

s77rt commented Mar 27, 2023

The checklist is has been provided here already #16354 (comment)

@strepanier03
Copy link
Contributor

@hellohublot and @s77rt - I have hired you both for the Upwork Job.


I've copied over rthe checklist responses into the checklist post, created the reg test GH, and I updated payment amounts (here).


Will be back to pay this once it's off hold.

@strepanier03 strepanier03 added Daily KSv2 and removed Weekly KSv2 labels Mar 30, 2023
@melvin-bot melvin-bot bot added Daily KSv2 and removed Daily KSv2 labels Mar 31, 2023
@strepanier03 strepanier03 changed the title [HOLD for payment 2023-04-03] [HOLD for payment 2023-03-31] [$1000] Setting - Console error appears and avatar is broken when uploading a photo to the profile [HOLD for payment 2023-03-31] [$1000] Setting - Console error appears and avatar is broken when uploading a photo to the profile Mar 31, 2023
@strepanier03 strepanier03 changed the title [HOLD for payment 2023-03-31] [$1000] Setting - Console error appears and avatar is broken when uploading a photo to the profile [PAID] [$1000] Setting - Console error appears and avatar is broken when uploading a photo to the profile Mar 31, 2023
@strepanier03
Copy link
Contributor

@hellohublot and @s77rt - I have paid out the jobs and ended the contracts. Thank you both for your hard work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests