API returns a ruby hash and not json
Created by: sklise
On Opsworks:
curl 'http://HOST/api/v3/projects/PROJECT_ID/repository/tree?ref_name=master' -H 'Origin: http://localhost:3000' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'PRIVATE-TOKEN: TOKEN' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: max-age=0' -H 'Connection: keep-alive' -H 'DNT: 1' --compressed
{"message"=>"500 Internal Server Error"}
This is happening because there is no repository for this project yet. Not only does the error code not say this but it is a ruby hash and not json.
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Author Owner
Created by: jvanbaarsen
@sklise Can you please post more loggin?
By Administrator on 2014-02-10T18:44:07 (imported from GitLab project)
By Administrator on 2014-02-10T18:44:07 (imported from GitLab)
- Author Owner
Created by: sklise
the complete curl request (minus token and IP):
curl 'http://HOSTNAME/api/v3/projects/atlasservers%2Fthis/repository/tree?ref_name=master' -H 'Origin: http://localhost:3000' -H 'PRIVATE-TOKEN: PRIVATE_TOKEN' -H 'Accept: application/json, text/javascript, */*; q=0.01' -D - HTTP/1.1 500 Internal Server Error Server: nginx Date: Mon, 10 Feb 2014 18:51:46 GMT Content-Type: application/json Content-Length: 40 Connection: keep-alive Status: 500 Internal Server Error Access-Control-Allow-Origin: http://localhost:3000 Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE Access-Control-Expose-Headers: Access-Control-Max-Age: 1728000 Access-Control-Allow-Credentials: true Vary: Origin Cache-Control: no-cache X-Request-Id: e80c989c-300a-455e-84f5-7ea6499c4f73 X-Runtime: 0.013670 {"message"=>"500 Internal Server Error"}
And the stack trace:
NoMethodError (undefined method `id' for nil:NilClass): /home/git/gitlab/lib/api/repositories.rb:144:in `block (2 levels) in <class:Repositories>' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/endpoint.rb:31:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/endpoint.rb:31:in `block in generate_api_method' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/endpoint.rb:401:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/endpoint.rb:401:in `run' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/endpoint.rb:154:in `block in call!' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/middleware/base.rb:24:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/middleware/base.rb:24:in `call!' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/middleware/base.rb:18:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/middleware/base.rb:24:in `call!' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/middleware/base.rb:18:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/middleware/error.rb:26:in `block in call!' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/middleware/error.rb:25:in `catch' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/middleware/error.rb:25:in `call!' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/middleware/base.rb:18:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/endpoint.rb:155:in `call!' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/endpoint.rb:145:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:152:in `block in call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in `block in recognize' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:124:in `optimized_each' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:95:in `recognize' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:141:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/api.rb:525:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/api.rb:42:in `call!' /home/git/gitlab/.bundle/ruby/2.0.0/gems/grape-0.6.1/lib/grape/api.rb:38:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/journey/router.rb:71:in `block in call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/journey/router.rb:59:in `each' /home/git/gitlab/.bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/journey/router.rb:59:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:680:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-cors-0.2.9/lib/rack/cors.rb:54:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-attack-2.3.0/lib/rack/attack.rb:63:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch' /home/git/gitlab/.bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/etag.rb:23:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/conditionalget.rb:25:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/params_parser.rb:27:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/flash.rb:241:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/cookies.rb:486:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/query_cache.rb:36:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:373:in `_run__3739460647155612605__call__callbacks' /home/git/gitlab/.bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in `run_callbacks' /home/git/gitlab/.bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/callbacks.rb:27:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/remote_ip.rb:76:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/rack/logger.rb:38:in `call_app' /home/git/gitlab/.bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/rack/logger.rb:20:in `block in call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:67:in `block in tagged' /home/git/gitlab/.bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:25:in `tagged' /home/git/gitlab/.bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:67:in `tagged' /home/git/gitlab/.bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/rack/logger.rb:20:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/request_id.rb:21:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/engine.rb:511:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:97:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:65:in `block in call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `each' /home/git/gitlab/.bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `call' /home/git/gitlab/.bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:552:in `process_client' /home/git/gitlab/.bundle/ruby/2.0.0/gems/unicorn-worker-killer-0.4.2/lib/unicorn/worker_killer.rb:51:in `process_client' /home/git/gitlab/.bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:632:in `worker_loop' /home/git/gitlab/.bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:500:in `spawn_missing_workers' /home/git/gitlab/.bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:142:in `start' /home/git/gitlab/.bundle/ruby/2.0.0/gems/unicorn-4.6.3/bin/unicorn_rails:209:in `<top (required)>' /home/git/gitlab/.bundle/ruby/2.0.0/bin/unicorn_rails:23:in `load' /home/git/gitlab/.bundle/ruby/2.0.0/bin/unicorn_rails:23:in `<main>'
By Administrator on 2014-02-10T18:52:46 (imported from GitLab project)
By Administrator on 2014-02-10T18:52:46 (imported from GitLab)
- Author Owner
Created by: jvanbaarsen
@sklise Is the project name:
atlasservers/this
?By Administrator on 2014-02-10T18:55:40 (imported from GitLab project)
By Administrator on 2014-02-10T18:55:40 (imported from GitLab)
- Author Owner
Created by: sklise
yes
By Administrator on 2014-02-10T18:58:01 (imported from GitLab project)
By Administrator on 2014-02-10T18:58:01 (imported from GitLab)
- Author Owner
Created by: jvanbaarsen
@sklise Can you try:
http://HOSTNAME/api/v3/projects/atlasservers/this/repository/tree?ref_name=master
as the URL?By Administrator on 2014-02-10T18:59:13 (imported from GitLab project)
By Administrator on 2014-02-10T18:59:13 (imported from GitLab)
- Author Owner
Created by: sklise
A 404 error as per the docs: http://api.gitlab.org/projects.html#get-single-project
By Administrator on 2014-02-10T19:01:58 (imported from GitLab project)
By Administrator on 2014-02-10T19:01:58 (imported from GitLab)
- Author Owner
Created by: jvanbaarsen
@sklise Sorry, missed that part
--Edit What API call are you trying to perform?
-- Edit 2 Im sorry, did not read your ticket correctly. Its because of no project exists. So it should not throw a nill class error, but it should return a valid error message. I will try to create a fix for this later tonight.
By Administrator on 2014-02-10T19:05:57 (imported from GitLab project)
By Administrator on 2014-02-10T19:05:57 (imported from GitLab)
- Author Owner
Created by: sklise
@jvanbaarsen The project was created via the api and returned a 201 response. But no repository has been pushed to the project yet.
By Administrator on 2014-02-10T20:08:26 (imported from GitLab project)
By Administrator on 2014-02-10T20:08:26 (imported from GitLab)
- Author Owner
Created by: jvanbaarsen
@sklise Can you please try adding the following code to:
lib/api/repositories.rb
line144
:not_found! "Commit" unless commit
Just under
commit = user_project.repository.commit(ref)
And try again?
By Administrator on 2014-02-10T20:13:15 (imported from GitLab project)
By Administrator on 2014-02-10T20:13:15 (imported from GitLab)
- Author Owner
Created by: sklise
I just experienced the same problem on another route in a different installation of Gitlab.
By Administrator on 2014-02-21T14:43:48 (imported from GitLab project)
By Administrator on 2014-02-21T14:43:48 (imported from GitLab)