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

REST API error responses should be in json format

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Bug
    • Affects Version/s: 3.36.0
    • Fix Version/s: None
    • Component/s: REST
    • Labels:
    • Notability:
      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

              Assignee:
              Unassigned Unassigned
              Reporter:
              msurani Mahendra Surani
              Last Updated By:
              Rich Seddon Rich Seddon
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response:

                  tigCommentSecurity.panel-title