Uploaded image for project: 'Dev - Nexus Repo'
  1. Dev - Nexus Repo
  2. NEXUS-29764

REST API error responses should be in json format

Details

    • Bug
    • Resolution: Not A Bug
    • Major
    • None
    • 3.36.0
    • REST
    • 4

    Description

      When you try to create a repository with a duplicate key, you get a database error string instead of a json formatted error.

      Create a repository that already exists with same name.
       

      curl -u admin:admin123 -v -X 'POST' \
       'http://localhost:8081/service/rest/v1/repositories/maven/hosted' \
       -H 'accept: application/json' \
       -H 'Content-Type: application/json' \
       -d '{
       "name": "maven-test-host",
       "online": true,
       "storage": {
       "blobStoreName": "default",
       "strictContentTypeValidation": true,
       "writePolicy": "allow_once"
       },
       "cleanup": {
       "policyNames": [
       "string"
       ]
       },
       "component": {
       "proprietaryComponents": true
       },
       "maven": {
       "versionPolicy": "MIXED",
       "layoutPolicy": "STRICT",
       "contentDisposition": "ATTACHMENT"
       }
      }'
      

      If that repo name already exists then it returns a 400 response.

      "Cannot index record #67:0: found duplicated key 'maven-test-host' in index 'repository_repository_name_idx' previously assigned to the record #66:0
      	DB name="config""
      

      Expected Behaviour

      Responses should be json format stating that repository maven-test-host already exists.

      The API should always return errors of the same format.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              msurani Mahendra Surani
              Michael Oliverio Michael Oliverio
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                tigCommentSecurity.panel-title