Skip to content

[HOLD for payment 2024-10-10] [$250] Profile - No error after uploading corrupted jpg for avatar, console error shows up #48707

Closed

Description

@lanitochka17

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


Version Number: 9.0.30-7
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): applausetester+kh010901@applause.expensifail.com
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to Account settings > Profile
  3. Click on the avatar > Upload photo
  4. Upload a corrupted jpg file (attached below)

Expected Result:

Error will show up saying that the file is corrupted

Actual Result:

Nothing happens after uploading corrupted jpg for avatar. Console error shows up

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6595141_1725613057700.20240906_165150.mp4

logs (2).txt

a

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021833355156424317364
  • Upwork Job ID: 1833355156424317364
  • Last Price Increase: 2024-09-10
  • Automatic offers:
    • Krishna2323 | Contributor | 103904041
Issue OwnerCurrent Issue Owner: @Ollyws

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 6, 2024
  2. melvin-bot commented on Sep 6, 2024

    @melvin-bot

    Triggered auto assignment to @RachCHopkins (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. lanitochka17 commented on Sep 6, 2024

    @lanitochka17
    Author

    @RachCHopkins FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

  4. Nodebrute commented on Sep 6, 2024

    @Nodebrute
    Contributor

    @lanitochka17 wrong file attached.

  5. Krishna2323 commented on Sep 6, 2024

    @Krishna2323
    Contributor

    Edited by proposal-police: This proposal was edited at 2024-09-06 12:57:22 UTC.

    Proposal


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

    Profile - No error after uploading corrupted jpg for avatar, console error shows up

    What is the root cause of that problem?

    There is no validation added for the corrupted images.

    const showAvatarCropModal = useCallback(
    (image: FileObject) => {
    if (!isValidExtension(image)) {
    setError('avatarWithImagePicker.notAllowedExtension', {allowedExtensions: CONST.AVATAR_ALLOWED_EXTENSIONS});
    return;
    }
    if (!isValidSize(image)) {
    setError('avatarWithImagePicker.sizeExceeded', {maxUploadSizeInMB: CONST.AVATAR_MAX_ATTACHMENT_SIZE / (1024 * 1024)});
    return;
    }
    isValidResolution(image).then((isValid) => {
    if (!isValid) {
    setError('avatarWithImagePicker.resolutionConstraints', {
    minHeightInPx: CONST.AVATAR_MIN_HEIGHT_PX,
    minWidthInPx: CONST.AVATAR_MIN_WIDTH_PX,
    maxHeightInPx: CONST.AVATAR_MAX_HEIGHT_PX,
    maxWidthInPx: CONST.AVATAR_MAX_WIDTH_PX,
    });
    return;
    }
    setIsAvatarCropModalOpen(true);
    setError(null, {});
    setIsMenuVisible(false);
    setImageData({
    uri: image.uri ?? '',
    name: image.name ?? '',
    type: image.type ?? '',
    });
    });
    },
    [isValidExtension, isValidSize],
    );

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


    • We should add the FileUtils.validateImageForCorruption(image) in the validation funtion.
    Pseudocode
       const showAvatarCropModal = useCallback(
           (image: FileObject) => {
               const handleError = (errorKey: string, errorParams: object) => {
                   setError(errorKey, errorParams);
                   setIsMenuVisible(false);
               };
    
               if (!isValidExtension(image)) {
                   handleError('avatarWithImagePicker.notAllowedExtension', {allowedExtensions: CONST.AVATAR_ALLOWED_EXTENSIONS});
                   return;
               }
    
               if (!isValidSize(image)) {
                   handleError('avatarWithImagePicker.sizeExceeded', {maxUploadSizeInMB: CONST.AVATAR_MAX_ATTACHMENT_SIZE / (1024 * 1024)});
                   return;
               }
    
               FileUtils.validateImageForCorruption(image)
                   .then(() => isValidResolution(image))
                   .then((isValid) => {
                       if (!isValid) {
                           handleError('avatarWithImagePicker.resolutionConstraints', {
                               minHeightInPx: CONST.AVATAR_MIN_HEIGHT_PX,
                               minWidthInPx: CONST.AVATAR_MIN_WIDTH_PX,
                               maxHeightInPx: CONST.AVATAR_MAX_HEIGHT_PX,
                               maxWidthInPx: CONST.AVATAR_MAX_WIDTH_PX,
                           });
                           return;
                       }
    
                       setIsAvatarCropModalOpen(true);
                       setError(null, {});
                       setIsMenuVisible(false);
                       setImageData({
                           uri: image.uri ?? '',
                           name: image.name ?? '',
                           type: image.type ?? '',
                       });
                   })
                   .catch(() => {
                       handleError('attachmentPicker.errorWhileSelectingAttachment', {});
                   });
           },
           [isValidExtension, isValidSize],
       );
    • I also think we should remove the alignSelfCenter style.
      style={[styles.pRelative, avatarStyle, type === CONST.ICON_TYPE_AVATAR && styles.alignSelfCenter]}
    • Or we can change the type when using AvatarWithImagePicker in ProfilePage.

    What alternative solutions did you explore? (Optional)

    Result

  6. RachCHopkins commented on Sep 9, 2024

    @RachCHopkins
    Contributor

    @Nodebrute what is the correct file for me to use for testing? Or, how does one create a "corrupted" jpeg file?

  7. Krishna2323 commented on Sep 9, 2024

    @Krishna2323
    Contributor

    @RachCHopkins, please use the file below for testing.

    corrupt_image

  8. RachCHopkins commented on Sep 10, 2024

    @RachCHopkins
    Contributor

    Reproduced. As a user it feels really weird cos just nothing happens.

  9. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 10, 2024
  10. changed the title [-]Profile - No error after uploading corrupted jpg for avatar, console error shows up[/-] [+][$250] Profile - No error after uploading corrupted jpg for avatar, console error shows up[/+] on Sep 10, 2024
  11. melvin-bot commented on Sep 10, 2024

    @melvin-bot
  12. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 10, 2024
  13. 20 remaining items

  14. melvin-bot commented on Oct 3, 2024

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.43-6 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 2024-10-10. 🎊

    For reference, here are some details about the assignees on this issue:

  15. melvin-bot commented on Oct 3, 2024

    @melvin-bot

    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:

    • [@Ollyws] The PR that introduced the bug has been identified. Link to the PR:
    • [@Ollyws] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
    • [@Ollyws] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
    • [@Ollyws] Determine if we should create a regression test for this bug.
    • [@Ollyws] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
    • [@RachCHopkins] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  16. RachCHopkins commented on Oct 10, 2024

    @RachCHopkins
    Contributor

    Contributor has been paid, the contract has been completed, and the Upwork post has been closed.

  17. RachCHopkins commented on Oct 10, 2024

    @RachCHopkins
    Contributor

    @Ollyws are there any regression tests needed here?

  18. Ollyws commented on Oct 11, 2024

    @Ollyws
    Contributor

    BugZero Checklist:

    • The PR that introduced the bug has been identified. Link to the PR:

    No PR was responsible this was just never added here.

    • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:

    N/A

    • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:

    N/A

    • Determine if we should create a regression test for this bug.

    Yes

    • If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
        1. Go to Account settings > Profile
        2. Click on the avatar > Upload photo
        3. Upload a corrupted jpg file (link can be found in https://github.com/Expensify/App/pull/49203)
        4. Verify error message is shown below the Avatar
    
  19. Ollyws commented on Oct 11, 2024

    @Ollyws
    Contributor

    @RachCHopkins Could we get a payment summary so I can request in ND? Thanks!

  20. RachCHopkins commented on Oct 14, 2024

    @RachCHopkins
    Contributor

    Sorry @Ollyws I didn't notice that Melvin left that little detail out!

    Payment Summary:

    • Contributor: @Krishna2323 paid $250 via Upwork
    • Contributor+: @Ollyws to be paid $250 via NewDot manual request

    Upwork job here

  21. Ollyws commented on Oct 14, 2024

    @Ollyws
    Contributor

    Requested in ND.

  22. garrettmknight commented on Oct 15, 2024

    @garrettmknight
    Contributor

    $250 approved for @Ollyws

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions