API Issue state endpoint returning 500 errors
Original notes
The issue seems to only happen for type=mr
because type=issue
succeeds.
This broken endpoint could be causing the warnings about Gitter connection issues, Unable to communicate with Gitter
https://gitter.im/gitterHQ/gitter?at=5e4681900c50da598c0dad69
I can't reproduce the warning reliably.
This issue is caused by the gitter-markdown-processor including GitLab specific /-/
part of issue or MR URL into parsed repository name.
This very issue https://gitlab.com/gitlab-org/gitter/webapp/-/issues/2453
would have repository name parsed as gitlab-org/gitter/webapp/-
.
Calling the /api/private/issue-state
endpoint with gitlab-org/gitter/webapp/-
as a repo results in our GitLabIssuableService
.getIssue() getting 404, handling the error badly and the endpoint returning 500.
I'm not sure why we started noticing the error recently. I've checked out a release 20.8.0
from 2019-11-11 and I was still able to reproduce the issue. My guess is that GitLab API was able to handle the trailing /-
in the past.
The fix
Fixing the root cause - markdown parsing
https://gitlab.com/gitlab-org/gitter/gitter-markdown-processor/-/merge_requests/23
GitLabIssuableService
Fixing the 404 handling in The /api/private/issue-state
should be able to handle non-existing repo by returning 404
, not 500
. **Even though that in this case it might have helped us to discover the issue.
Temporary UI fix for malformed repo URLs
There is a plenty already parsed messages in the DB with malformed URL like:
<a target="_blank" data-link-type="issue" data-issue="2453" href="https://gitlab.com/gitlab-org/gitter/webapp/-/issues/2453" data-provider="gitlab" data-issue-repo="gitlab-org/gitter/webapp/-" class="issue">gitlab-org/gitter/webapp/-#2453</a>
I'm suggesting to implement temporary (~ 6 months) fix that will remove /-
at the end of repository URL in UI.
We hardcode this replacement to issuableDecorator.js
so it stops sending malformed repo names to the /api/private/issue-state
endpoint.