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

Staging move may fail against a repo created by Repository API

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 3.29.1, 3.30.1, 3.32.0
    • Fix Version/s: None
    • Component/s: REST, Staging
    • Labels:
    • Notability:
      3

      Description

      SYMPTOM:

      The Staging move API against the repository created by the Repository API fails if same file already exists even with the write policy "allow".

      REPRODUCE STEPS:

      1. Install NXRM3 v3.29.1 or higher
      2. Create two test repos: "REPO_bad" and "REPO_good":
        curl -u admin:admin123 -X POST "http://localhost:8081/service/rest/v1/repositories/raw/hosted" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"name\": \"REPO_bad\", \"online\": true, \"storage\": { \"blobStoreName\": \"default\", \"strictContentTypeValidation\": false, \"writePolicy\": \"allow\" }, \"cleanup\": null, \"component\": { \"proprietaryComponents\": false }, \"raw\": { \"contentDisposition\": \"ATTACHMENT\" }}"
        curl -u admin:admin123 -X POST "http://localhost:8081/service/rest/v1/repositories/raw/hosted" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"name\": \"REPO_good\", \"online\": true, \"storage\": { \"blobStoreName\": \"default\", \"strictContentTypeValidation\": false, \"writePolicy\": \"ALLOW\" }, \"cleanup\": null, \"component\": { \"proprietaryComponents\": false }, \"raw\": { \"contentDisposition\": \"ATTACHMENT\" }}"
      1. Upload two test file to each repository:
        curl -u admin:admin123 -T<(echo "aaaa") http://localhost:8081/repository/REPO_bad/aaaa.txt
        curl -u admin:admin123 -T<(echo "aaaa") http://localhost:8081/repository/REPO_good/aaaa.txt
      1. (Optional) Just in case, making sure the files have been uploaded
        curl -u admin:admin123 "http://localhost:8081/service/rest/v1/search?repository=REPO_bad&name=aaaa.txt" | python -m json.tool
        curl -u admin:admin123 "http://localhost:8081/service/rest/v1/search?repository=REPO_good&name=aaaa.txt" | python -m json.tool
      1. Move from the bad repo to the good repo:
        curl -u admin:admin123 -v -X POST "http://localhost:8081/service/rest/v1/staging/move/REPO_good?repository=REPO_bad&name=aaaa.txt"
      1. Move from the good repo to the bad repo (after re-uploading the test file):
        curl -u admin:admin123 -T<(echo "aaaa") http://localhost:8081/repository/REPO_bad/aaaa.txt
        curl -u admin:admin123 -v -X POST "http://localhost:8081/service/rest/v1/staging/move/REPO_bad?repository=REPO_good&name=aaaa.txt"

      EXPECTED BEHAVIOUR:

      The last two move commands should work.

      ACTUAL BEHAVIOUR:

      The last curl command fails with below error:

        "status" : 400,
        "message" : "Destination already contains component: group=/, name=aaaa.txt, version=null, format=raw",
        "data" : {
          "source" : {
            "repository" : "REPO_good",
            "format" : "raw"
          },
          "destination" : {
            "repository" : "REPO_bad",
            "format" : "raw"
          }
        }
      

      CAUSE:

      Currently the Repository API accepts the values "allow" (small letters) and "ALLOW" for the writePolicy.
      However, com.sonatype.nexus.staging.internal.orient.OrientStagingComponentManager#redeployNotAllowed does the case sensitive comparison.  Might want to check to make sure this is not free text

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              hosako Hajime Osako
              Last Updated By:
              Joe Tom Joe Tom
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response:

                  tigCommentSecurity.panel-title