contacts icon indicating copy to clipboard operation
contacts copied to clipboard

Add check for empty search result

Open miaulalala opened this issue 3 years ago β€’ 4 comments

Fixes array accessor error for #2721

Does not fix the underlying issue of empty contacts when social data should be accessible.

miaulalala avatar May 11 '22 08:05 miaulalala

Codecov Report

Merging #2736 (3a0b600) into main (53390f4) will increase coverage by 0.07%. The diff coverage is 100.00%.

@@             Coverage Diff              @@
##               main    #2736      +/-   ##
============================================
+ Coverage     18.04%   18.12%   +0.07%     
  Complexity      247      247              
============================================
  Files            97       97              
  Lines          3170     3173       +3     
  Branches        439      439              
============================================
+ Hits            572      575       +3     
  Misses         2405     2405              
  Partials        193      193              
Impacted Files Coverage Ξ”
lib/Service/SocialApiService.php 90.72% <100.00%> (+0.18%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data Powered by Codecov. Last update 53390f4...3a0b600. Read the comment docs.

codecov[bot] avatar May 11 '22 08:05 codecov[bot]

Hi @miaulalala and thank you so much for helping out! Concerning your proposal, I am afraid suppressing the error messages is only fighting the symptoms. We need to find out why the update is not working for some users anymore.

call-me-matt avatar May 11 '22 16:05 call-me-matt

As stated above, I am not happy with this solution. Can we find a compromise to at least print out a dedicated warning message when the UID is not found? When a user wishes to update a contact and the function returns a precondition failed, it is not good. It just hides the problem, as a precondition failed in this function means that the contact does not have any social data. But in fact, this seems to be triggered for all contacts in certain setups and makes the update for all disfunctional. At best, I would like to find out how this can ever happen and eliminate the root of the issue.

call-me-matt avatar May 13 '22 06:05 call-me-matt

As stated above, I am not happy with this solution. Can we find a compromise to at least print out a dedicated warning message when the UID is not found? When a user wishes to update a contact and the function returns a precondition failed, it is not good. It just hides the problem, as a precondition failed in this function means that the contact does not have any social data. But in fact, this seems to be triggered for all contacts in certain setups and makes the update for all disfunctional. At best, I would like to find out how this can ever happen and eliminate the root of the issue.

Right, I agree, if there is an underlying problem with the social API this of course should also be fixed. Doesn't change the fact that using an array accessor without checking if the array isn't empty is bad practice and should be avoided. I can add some logging to inform the user :v:

miaulalala avatar May 13 '22 10:05 miaulalala

Superseded by https://github.com/nextcloud/contacts/pull/2869

ChristophWurst avatar Dec 15 '22 15:12 ChristophWurst