Commit 463c8c66 authored by Harsh Chouraria's avatar Harsh Chouraria Committed by Kerri Miller

Expose HTTP code during GitHub importer errors

This change adjusts the message returned to the user
when a GitHub import operation fails to include the
response HTTP code.

This is useful when the HTTP body is empty, such as
during the use of reverse proxies in accessing a
GitHub Enterprise instance over the internet.

The presence of a HTTP code can help establish if
a connection was at least made successfully and
the HTTP code can further be traced in their own
proxy or GitHub Enterprise logging for further
troubleshooting.

The logs already carry this information, but on
SaaS this is currently not visible due to
https://gitlab.com/gitlab-com/gl-infra/reliability/-/issues/15470

Changelog: other
parent d742fcad
......@@ -117,7 +117,7 @@ module Import
error: exception.response_body
)
error(_('Import failed due to a GitHub error: %{original}') % { original: exception.response_body }, :unprocessable_entity)
error(_('Import failed due to a GitHub error: %{original} (HTTP %{code})') % { original: exception.response_body, code: exception.response_status }, :unprocessable_entity)
end
def log_and_return_error(message, translated_message, http_status)
......
......@@ -18864,7 +18864,7 @@ msgstr ""
msgid "Import and export rate limits"
msgstr ""
msgid "Import failed due to a GitHub error: %{original}"
msgid "Import failed due to a GitHub error: %{original} (HTTP %{code})"
msgstr ""
msgid "Import from"
......
......@@ -34,11 +34,11 @@ RSpec.describe Import::GithubService do
subject.execute(access_params, :github)
end
it 'returns an error' do
it 'returns an error with message and code' do
result = subject.execute(access_params, :github)
expect(result).to include(
message: 'Import failed due to a GitHub error: Not Found',
message: 'Import failed due to a GitHub error: Not Found (HTTP 404)',
status: :error,
http_status: :unprocessable_entity
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment