Error 500 while getting all projects using the API

Hi,

I know there are more issue about this topic, but no answer for me to solve this issue.
For some reasons I will get a 500 error calling the next AP url /api/v4/projects, while calling /api/v4/users returns a result.

GitLab edtion: Community Editor 12.7.2

Can anyone help me about this?

Kind regards,
Wouter Splinter

Hi,

500 generally means an error on the server. Please check the production log from the GitLab server to unveil more details on the problem.

Cheers,
Michael

Hi Michael,

The first contents when the error starts of the production log is:

Started GET "/api/v4/projects/" for 126.0.57.173 at 2020-01-29 09:08:50 +0100
Processing by Gitlab::RequestForgeryProtection::Controller#index as HTML
Completed 200 OK in 0ms (ActiveRecord: 0.0ms | Elasticsearch: 0.0ms)
Processing by Gitlab::RequestForgeryProtection::Controller#index as HTML
Completed 200 OK in 0ms (ActiveRecord: 0.0ms | Elasticsearch: 0.0ms)

URI::InvalidComponentError (bad component(expected host component): ptire_redmine):
/opt/gitlab/embedded/lib/ruby/2.6.0/uri/generic.rb:592:in `check_host'
/opt/gitlab/embedded/lib/ruby/2.6.0/uri/generic.rb:631:in `host='
/opt/gitlab/embedded/lib/ruby/2.6.0/uri/generic.rb:664:in `hostname='
/opt/gitlab/embedded/lib/ruby/2.6.0/uri/generic.rb:191:in `initialize'
/opt/gitlab/embedded/lib/ruby/2.6.0/uri/generic.rb:137:in `new'
/opt/gitlab/embedded/lib/ruby/2.6.0/uri/generic.rb:137:in `build'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/helpers/related_resources_helpers.rb:29:in `expose_url'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/entities.rb:254:in `block (2 levels) in <class:Project>'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-entity-0.7.1/lib/grape_entity/entity.rb:494:in `instance_exec'

I do not understand what causes the error.

Wouter

Hi,

this sounds a bit as if an URL would be malformed, either missing or adding unwanted http prefixes. Can you share the call you are using against the REST API? If you need to obfuscate, please only replace (domain) names with some sensitive default.

Cheers,
Michael

Hi,

Ofcourse, the following URL returns a 500 error:
http://servername:8090/api/v4/projects/

The follwing returns a json result with data:
http://servername:8090/api/v4/users/

Regards,
Wouter

Hi,

ok, weird. I would guess that none of your request arguments includes redmine, right?

Are you by chance using the Redmine integration where ptire_redmine is the hostname of your Redmine server?

Cheers,
Michael

Hi,

That’s right, none of our request arguments includes redmine.
Only GitLab was installed seperately on a server where already redmine was installed. It runs side by side.

redmine on port 80
gitlab on port 8090

So only de servername is ptire_redmine, we are not doing anything with redmine (that is another department).

Regards,
Wouter

Hi,

ah, ok, that sheds some light here. Are you by chance using the short ptire_redmine name, instead of a fully qualified domain name?

As in,

http://ptire_redmine:8090

instead of

http://ptire_redmine.internal.company.com:8090

If that is not the culprit, I need to guess further e.g. with GitLab settings and external_url :wink:

Cheers,
Michael

Sorry, I am already using
http://ptire_redmine:8090

Can you use an FQDN instead?

I’m sorry, but what is an FQDN and what can I do with it?
I’m realy a noob about this topic :slight_smile:

Run hostname -f on your server to see the fully qualified domain name (FQDN).

The FQDN is ptire_redmine

Hm. Out of guesses. Can you share the complete command you are firing against this URL endpoint?

Hmmm, that’s too bad :frowning:, but thanks for all your help to fix this issue

But I only type the API URL in the address bar of the browser…

the following URL returns a 500 error:
http://ptire_redmine:8090/api/v4/projects/

The follwing returns a json result with data:
http://ptire_redmine:8090/api/v4/users/

It weird that users works fine en projects gives an error

Ah, so you are using the auth token from your user’s session in the browser. Is there are difference when you do that with curl on the shell?

curl -H 'PRIVATE-TOKEN: XXX' http://ptire_redmine:8090/api/v4/projects/

And since I see that, does it make a difference if you omit the last trailing slash?

Like,

http://ptire_redmine:8090/api/v4/projects

?

Goodmorning,

I have tried what you said, but unfortunately the same result :frowning:
{"message":"500 Internal Server Error"}

Hi,

I am out of guesses unfortunately. Maybe this is a bug in 12.7.2, did you try searching for issues already? Might not hurt to create a new one with the details we collected here already. My guess is that engineers will know better than me :slight_smile:

Cheers,
Michael

Hi Michael,

Don’t worry, but thanks for all your help, and I’ll make an issue about this problem.
It is no problem in the version which I’ve installed, in the previous one I had the same problem.

Thanks,
Wouter

@dnsmichi,

I’ve solved this problem. It was related to the underscore in the URL. We’ve replaced the external_url without and underscore and it works.

Regards,
Wouter

2 Likes