objectcomputing / check-ins

Other
7 stars 6 forks source link

(Backend) - Bad Request When App Loads Users Without Photos #2366

Open mjperry91 opened 6 months ago

mjperry91 commented 6 months ago

When logging in or opening various pages that load users you may occasionally run into a bad request in the server logs when a user does not have an image. Since it is possible for a user to have no image, then the end point handling this should not throw a bad request. Note: The service does seem to recover from this error so likely low priority.

  1. Start app with fresh database
  2. Login (Other tabs such as Admin/Roles has this issue as well)
  3. Observe Error
    10:03:01.868 [io-executor-thread-21] INFO  c.o.c.s.m.m.MemberPhotoServiceImpl - No photo was found for: undefined
    10:03:01.868 [io-executor-thread-28] INFO  c.o.c.s.m.m.MemberPhotoServiceImpl - No photo was found for: testing@objectcomputing.com
    10:03:01.886 [io-executor-thread-22] INFO  c.o.c.s.m.m.MemberPhotoServiceImpl - No photo was found for: testing2@objectcomputing.com
    10:03:02.126 [io-executor-thread-27] ERROR c.o.c.s.m.m.MemberPhotoServiceImpl - An unexpected error occurred while retrieving photo from Google Directory API for: smithj@objectcomputing.com
    com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
    GET https://www.googleapis.com/admin/directory/v1/users/smithj@objectcomputing.com/photos/thumbnail
    {
    "code" : 400,
    "errors" : [ {
    "domain" : "global",
    "message" : "Type not supported: userKey",
    "reason" : "badRequest"
    } ],
    "message" : "Type not supported: userKey"
    }
        at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:150)
        at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
        at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:444)
        at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1111)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:542)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:475)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:592)
        at com.objectcomputing.checkins.services.memberprofile.memberphoto.MemberPhotoServiceImpl.getImageByEmailAddress(MemberPhotoServiceImpl.java:56)
        at com.objectcomputing.checkins.services.memberprofile.memberphoto.$MemberPhotoServiceImpl$Definition$Intercepted.$$access$$getImageByEmailAddress(Unknown Source)
        at com.objectcomputing.checkins.services.memberprofile.memberphoto.$MemberPhotoServiceImpl$Definition$Exec.dispatch(Unknown Source)
timyates commented 6 months ago

I'm not sure what it causing this 🤔

We are seeing users with no photo correctly returning a 404 from the Google API and logging

No photo was found for: xxxxxx

But then we have 4 users in the dev dataload who are returning a 400 error consistently; sharma, smith, steinkamp and meyerin

I wonder if their accounts were partially closed in google, or there's something I can't see that they have in common that other email addresses that are also not in google (but return a 404 correctly) have 🤔