Skip to content

fix(gitlab): Handle JSONDecodeError#27682

Merged
MeredithAnya merged 3 commits into
masterfrom
meredith/fix-SENTRY-RKE
Jul 22, 2021
Merged

fix(gitlab): Handle JSONDecodeError#27682
MeredithAnya merged 3 commits into
masterfrom
meredith/fix-SENTRY-RKE

Conversation

@MeredithAnya

Copy link
Copy Markdown
Member

We are getting a JSONDecodeError when gitlab responds back with a 301 on refreshing identities because we attempt to get the status code from the decoded json when there isn't any. Let's just use the response code from the req so that we actually can log the refresh failures (currently we aren't logging it at all)

FIXES SENTRY-RKE

@MeredithAnya MeredithAnya requested a review from a team July 22, 2021 17:29
@mgaeta

mgaeta commented Jul 22, 2021

Copy link
Copy Markdown
Contributor

I think we should only use req.status_code when the error type is JSONDecodeError and in all other cases user e.code. We could do something like

"error_status": e.code if hasattr(e, "code") else req.status_code,

or

"error_status": getattr(e, "code", req.status_code),

or

except JSONDecodeError as e:
  code = req.status_code
  self.logger(...)
except Exception as e:  
  code = e.code
  self.logger(...)

@mgaeta mgaeta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but you should leave a comment explaining why e.code might not exist.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants