Bug 484579

Summary: Cannot create EWS Account Resource
Product: [Frameworks and Libraries] Akonadi Reporter: domhans
Component: EWS ResourceAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: carl, jsardid, krissn, m_louis30, xeno
Priority: NOR    
Version: 6.0.1   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description domhans 2024-03-27 07:42:39 UTC
SUMMARY

Since yesterday my Outlook EWS Account stopped synchronizing, and I got an error authentication failed. 
Manual re-authentication not possible, a manual account setting and 'try connect' was not possible, not settings window opened.

So I deleted the ews account from kmail and tried to re-add it again.

kmail settings -> configure kmail -> accounts (receiving)  -> add custom account -> select Microsoft exchange EWS

The settings window appears for few (1-2) seconds and disappears. 
This happens each time I try to access settings

STEPS TO REPRODUCE
1. always, see above



ADDITIONAL INFORMATION
Akonadi output when trying to add ews resource:

org.kde.pim.akonadiserver: New notification connection (registered as Akonadi::Server::NotificationSubscriber(0x7f9df427e0f0) )
org.kde.pim.akonadiserver: Subscriber Akonadi::Server::NotificationSubscriber(0x7f9df427e0f0) identified as "AgentBaseChangeRecorder - 105915778054496"
QWindow::fromWinId(): platform plugin does not support foreign windows.
org.kde.pim.ews.client: Failed to retrieve authentication data
org.kde.pim.ews.client: Failed to retrieve authentication data
org.kde.pim.ews: Authentication failed:  Password request failed
org.kde.pim.ews: reauthenticate: trying to refresh
org.kde.pim.ews.client: Failed to process EWS request: 
org.kde.pim.ews: requestAuthFailed - going offline
org.kde.pim.ews.client: Failed to process EWS request: 
ASSERT: "req->responses().size() == sourceIds.size()" in file ./resources/ews/ewssubscribedfoldersjob.cpp, line 57
org.kde.pim.akonadiserver: Subscriber "AgentBaseChangeRecorder - 105915778054496" disconnected
org.kde.pim.akonadicontrol: ProcessControl: Application "/usr/bin/akonadi_ews_resource" stopped unexpectedly ( "Process crashed" )
org.kde.pim.akonadicontrol: Application '/usr/bin/akonadi_ews_resource' crashed! 1 restarts left.
org.kde.pim.akonadiserver: New notification connection (registered as Akonadi::Server::NotificationSubscriber(0x7f9df41761e0) )
org.kde.pim.akonadiserver: Subscriber Akonadi::Server::NotificationSubscriber(0x7f9df41761e0) identified as "AgentBaseChangeRecorder - 101647180432544"
org.kde.pim.ews.client: Failed to process EWS request: 
org.kde.pim.ews: "Invalid number of responses received"
org.kde.pim.ews: requestAuthFailed - going offline
org.kde.pim.ews: reauthenticate: trying to refresh
org.kde.pim.ews.client: Failed to process EWS request: 
org.kde.pim.ews: "Invalid number of responses received"
org.kde.pim.ews: requestAuthFailed - going offline
org.kde.pim.ews: reauthenticate: trying to refresh
org.kde.pim.ews.client: Failed to process EWS request: 
org.kde.pim.ews: "Invalid number of responses received"
org.kde.pim.ews: requestAuthFailed - going offline
Comment 1 Louis Moureaux 2024-03-27 23:07:10 UTC
I get the same behavior since today with a similar assert in a different location:

ASSERT: "responses.size() == itemsToDo" in file ./resources/ews/ewsabstractchunkedjob.h, line 87

Both seem related to not receiving as many responses as expected.

Relevant part of the log:
==============================================
org.kde.pim.ews.client: Failed to process EWS request: 
org.kde.pim.ews: "Invalid number of responses received"
org.kde.pim.ews: requestAuthFailed - going offline
org.kde.pim.ews: reauthenticate: trying to refresh
org.kde.pim.ews.client: Starting OAuth2 authentication
org.kde.pim.kimap: sasl_client_start failed with: -4 "SASL(-4): no mechanism available: No worthy mechs found"
org.kde.pim.ews.client: Failed to process EWS request: 
ASSERT: "responses.size() == itemsToDo" in file ./resources/ews/ewsabstractchunkedjob.h, line 87
org.kde.pim.akonadicontrol: ProcessControl: Application "/usr/bin/akonadi_ews_resource" stopped unexpectedly ( "Le processus a planté" )
org.kde.pim.akonadicontrol: Application '/usr/bin/akonadi_ews_resource' crashed! 1 restarts left.
==============================================

Operating System: KDE neon 6.0
KDE Plasma Version: 6.0.3
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.5.0-26-generic (64-bit)
Comment 2 avlas 2024-06-28 14:09:06 UTC
This happens to me as well. 

Is there a way to workaround this? 

I cannot even get to know if EWS works or not in kmail as I cannot configure the account.

Thanks
Comment 3 Bug Janitor Service 2024-07-08 22:05:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/pim/kdepim-runtime/-/merge_requests/174
Comment 4 Carl Schwan 2024-09-06 13:51:19 UTC
Git commit 586bbacf6990e5d8264a4a0c5884f03458a8d969 by Carl Schwan.
Committed on 06/09/2024 at 13:50.
Pushed by carlschwan into branch 'master'.

Forward network error to the resouce

job->error and job->errorString are always empty and so the error was
not forwarded. Due to it not being forwarded, this made the EWS request
believe it was successful, which then crashed due to the response data
being empty.
Related: bug 485799
Fixed-In: 24.08.0

M  +1    -1    resources/ews/ewsclient/ewsrequest.cpp

https://invent.kde.org/pim/kdepim-runtime/-/commit/586bbacf6990e5d8264a4a0c5884f03458a8d969
Comment 5 Carl Schwan 2024-09-06 13:53:00 UTC
Git commit 13bda2e41f84df8ba04df0e32be6c213a56be121 by Carl Schwan.
Committed on 06/09/2024 at 13:52.
Pushed by carlschwan into branch 'release/24.08'.

Forward network error to the resouce

job->error and job->errorString are always empty and so the error was
not forwarded. Due to it not being forwarded, this made the EWS request
believe it was successful, which then crashed due to the response data
being empty.
Related: bug 485799
Fixed-In: 24.08.0


(cherry picked from commit 586bbacf6990e5d8264a4a0c5884f03458a8d969)

Co-authored-by: Carl Schwan <carl@carlschwan.eu>

M  +1    -1    resources/ews/ewsclient/ewsrequest.cpp

https://invent.kde.org/pim/kdepim-runtime/-/commit/13bda2e41f84df8ba04df0e32be6c213a56be121