Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #2409

Closed
Open
Created Dec 27, 2012 by Administrator@rootOwner

Bad API URL's return HTTP 500; propose returning HTTP 404 instead

Created by: cyvasse

I was trying out the Gitlab API. The docs clearly state that the URL is /api/v3/projects, but for some reason I tried /api/projects instead. This returned HTTP 500 due to a NoMethodError in project.rb. I eventually figured out that it should be /api/v3/projects.

I would have figured out my mistake faster if the result had been HTTP 404 instead. Since HTTP 404 is a more appropriate error code for an incorrect URL, I'd like to propose the fix mentioned in the issue title: Non-existing URL's under /api should return HTTP 404.

The command that gives the 500 is:

wget 'http://localhost/api/projects?private_token=abcdefgh12345678xxxx'

In /home/gitlab/gitlab/log/production.log the following information:

Started GET "/api/projects?private_token=abcdefgh12345678xxxx" for 127.0.0.1 at 2012-12-27 07:30:31 +0000
Processing by ProjectsController#show as */*
  Parameters: {"private_token"=>"abcdefgh12345678xxxx", "id"=>"api/projects"}
Completed 500 Internal Server Error in 65ms

NoMethodError (undefined method `id' for nil:NilClass):
  app/models/project.rb:104:in `find_with_namespace'
  app/controllers/application_controller.rb:69:in `project'

Details about my setup: I just did my first Gitlab install from 4-0-stable. I tried the above command before uploading any repos, and again after pushing one repo; both gave the same results. I installed everything to the recommended paths and usernames. The most recent commit in the gitlab server's tree at /home/gitlab/gitlab is c68540e9. I haven't tried other API URL's. I used my actual private token as displayed in the /profile/account URL when I ran the above command, but I replaced it with abcdefgh... in this description to keep my private token private.

Assignee
Assign to
Time tracking