OfficeDev / office-js

A repository for issues related to the Office JavaScript APIs and Office Add-ins platform. Find the Office.js library in Office.js CDN: https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
725 stars 106 forks source link

Office.context.mailbox.item.removeAttachmentAsync() call fails when removing attachments from multiple drafts #5502

Closed MehakFatima24 closed 2 weeks ago

MehakFatima24 commented 1 month ago

Provide required information needed to triage your issue

Your Environment

Expected behavior

The attachments should be removed successfully from each draft.

Current behavior

Currently the attachments fail randomly, and the following error shows up on Outlook: "The following attachments couldn't be deleted: . Please try again later." when we check the errors with the api (https://outlook.office.com/owa/service.svc?action=DeleteAttachment&app=Mail&n=), the response status code is 200 however when we take a look at the response there is a mismatch in the change key "The send or update operation could not be performed because the change key passed in the request does not match the current change key for the item., Cannot save changes made to an item to store.SaveStatus: IrresolvableConflict\r\nPropertyConflicts:\r\n"

Steps to reproduce

  1. Create multiple drafts
  2. Add attachments in each draft 4+
  3. Switch between drafts
  4. Open a draft and remove all attachments
  5. Open another draft and remove attachments till you run into the problem

Context

The attachments are automatically removed by our add-in when the user clicks send. However, with this error the send button remains greyed out and the user remains stuck. This is negatively impacting a significant user base for our add-in.

Useful logs

Image

Image

Image

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

github-actions[bot] commented 1 month ago

Here are some similar issues that might help you. Please check if they can solve your problem.

Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)

Solution 1:

This issue is mostly happening because the mail item is being saved by two entities (removeAttachments and setCustomProperties), sometimes causing a conflict at the server side. Implement the logic of retries while removing the attachments. Run a loop for 3 retries, if successful exit the loop, else delay the next retry by 1 or 2 seconds. This should resolve the issue.

Reference:

Reference:

Powered by issue-sentinel

arpitsangwanmsft commented 1 month ago

Hey @MehakFatima24 ! Can you please help with a couple of questions for better understanding the issue:

It would be really helpful If you can provide us with a sample addin through which we can repro this scenario, if not possible can you please provide sample code of how your Add-in is setup and has been calling above mentioned APIs?

Thanks

MehakFatima24 commented 1 month ago

Hi @arpitsangwanmsft

Here's a snippet of the code that we use to remove the attachments once the message is sent.

Image
lnnrtngl commented 1 month ago

@exextoc, @arpitsangwanmsft

This issue is a critical blocker for our users transitioning from Outlook classic to OWA. The inability to reliably remove attachments from drafts is causing significant disruption, as users are unable to send these emails

The problem persists even with manual retries, especially with image attachments, and the misleading 200 response complicates debugging..

Currently this is undermining user confidence in the new OWA interface and impacting productivity significantly for our users

We need a resolution or workaround. Any updates or tips on this would be greatly appreciated

arpitsangwanmsft commented 1 month ago

Hey @lnnrtngl/ @MehakFatima24! We tried to repro above mentioned scenario with multiple drafts containing multiple attachments as mentioned in the repro step with the provided code snippet but could not repro it.

For faster diagnosis could you please create a sample addin with which you can repro and share the addin with us. Also please include a screen recording of the repro scenario if possible. Without the sample addin and recording, I am not sure where event.completed has been called, what kind of attachments are involved and a few other ambiguities.

Also, can you please confirm, does the office.js removeAttachmentAsync api also return success in case attachment deletion fails?

Thanks

MehakFatima24 commented 1 month ago

@arpitsangwanmsft I have shared a private repo with you, it has the video with reproduction steps. I am also creating a scriptlab snippet for you to reproduce the issue

to answer your question. Yes, office.js removeAttachmentAsync returns success.

arpitsangwanmsft commented 1 month ago

Hey @MehakFatima24! General attachment deletion failure as showcased in shared video, is not governed by office.js APIs. This forum is limited to office-js related queries. For Outlook specific queries and support please post your questions here -  https://support.microsoft.com/home/contact.

However, we can assist if removeAttachmentAsync is returning success in this scenario. On basis of which, retry logic can be implemented.

MehakFatima24 commented 1 month ago

@arpitsangwanmsft as shared in the screenshots above this is an office.js api failure but it returns a 200 status, I have also attached screenshots of the response from office js above.

Kindly elaborate on how to implement the retry mechanism when the removeAttachmentAsync is successful?

this is the api endpoint ( https://outlook.office.com/owa/service.svc?action=DeleteAttachment&app=Mail&n=179) and the error I get is "The send or update operation could not be performed because the change key passed in the request does not match the current change key for the item., Cannot save changes made to an item to store.SaveStatus: IrresolvableConflict\r\nPropertyConflicts:\r\n", in the request response with 200 status.

Image
MehakFatima24 commented 1 month ago

@arpitsangwanmsft I have uploaded the code for a sample addin in the same repository.

rajjha-msft commented 4 weeks ago

Hey @MehakFatima24

Can you please share it with @exextoc ?

rajjha-msft commented 4 weeks ago

I went through the shared add-in and it has no OnSend logic. The only extension point it covers is read. Please share an add-in which can be used to repro the issue.

MehakFatima24 commented 4 weeks ago

@rajjha-msft , the original add-in does have the on-send logic but as you see in the video, the on-send event is not triggered and the bug can be reproduced without the user clicking send button.

MehakFatima24 commented 4 weeks ago

I have shared the access with @exextoc and @rajjha-msft!

lnnrtngl commented 3 weeks ago

Hey @exextoc, @rajjha-msft, can we have an update on this?

This is impacting productivity significantly for our end users.. It would be great if there is a workaround or fix on this

rajjha-msft commented 3 weeks ago

Hey @lnnrtngl

I did see the video and receive the add-in. I can see the error happens when we try to remove attachments form the drafts. And I unsderstand the use case, due to the same there are issues with ItemSend.

Unfortunately, we are not able to reprouce the issue at our end, and we do not own the internal atatchment Apis. But are working to loop in the right set of people for the same.

Before that, can you please answer the questions below

Apologies for the delay here.

MehakFatima24 commented 3 weeks ago

Hi @rajjha-msft ,

lnnrtngl commented 2 weeks ago

Hey @rajjha-msft, can we have a follow-up on this?

kumarshrey-msft commented 2 weeks ago

Hi @MehakFatima24,

We were able to reproduce this bug. Upon investigation, we identified this as a manifestation of bug #4610. I am closing this as duplicate, you can folllow #4610 for future updates.

To help you get unblocked in the meantime, can you add a callback in the removeAttachmentAsync API where you can call getAttachmentsAsync to fetch list of available IDs to check if any of the attachments which should have been removed still persist, and subsequenlty remove them?