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

Content selector creation REST API does not check for duplicates

    Details

    • Story Points:
      3
    • Sprint:
      NXRM Neo Sprint 31
    • Notability:
      4
    • InvestmentLayer:
      support-escalated
    • Aha Concept:
      non-concept

      Description

      1. Go to the "POST /v1/security/content-selectors" REST API in the swagger UI.
      2. Press "try it out"
      3. Press "execute"

      Result: success, as expected

      Now press "execute" again.

      Result, a 500 response, and a scary looking exception in the log.

      Expected: A 400 response, ideally with a message indicating that the selector already exists.

      2020-02-20 13:50:31,771-0600 WARN [qtp638251305-163] admin org.sonatype.nexus.siesta.internal.UnexpectedExceptionMapper - (ID 58a49e7c-c6cc-4ddc-8390-eecc2d9daaad) Response: [500] 'ERROR: (ID 58a49e7c-c6cc-4ddc-8390-eecc2d9daaad) com.orientechnologies.orient.core.storage.ORecordDuplicatedException: Cannot index record #76:1: found duplicated key 'string' in index 'selector_selector_name_idx' previously assigned to the record #76:0
      DB name="config" INDEX=selector_selector_name_idx RID=#76:0'; mapped from: com.orientechnologies.orient.core.storage.ORecordDuplicatedException: Cannot index record #76:1: found duplicated key 'string' in index 'selector_selector_name_idx' previously assigned to the record #76:0
      DB name="config" INDEX=selector_selector_name_idx RID=#76:0
      2020-02-20 13:50:32,871-0600 WARN [qtp638251305-163] admin org.sonatype.nexus.siesta.internal.UnexpectedExceptionMapper - (ID 99e4f046-e404-4a50-83fc-98dfdfa99622) Unexpected exception: com.orientechnologies.orient.core.storage.ORecordDuplicatedException: Cannot index record #77:0: found duplicated key 'string' in index 'selector_selector_name_idx' previously assigned to the record #76:0
      DB name="config" INDEX=selector_selector_name_idx RID=#76:0
      com.orientechnologies.orient.core.storage.ORecordDuplicatedException: Cannot index record #77:0: found duplicated key 'string' in index 'selector_selector_name_idx' previously assigned to the record #76:0
      DB name="config"
      at com.orientechnologies.orient.core.index.OIndexUnique$1.validate(OIndexUnique.java:47)
      at com.orientechnologies.orient.core.index.OIndexUnique$1.validate(OIndexUnique.java:37)
      at com.orientechnologies.orient.core.index.sbtree.local.OSBTree.put(OSBTree.java:855)
      at com.orientechnologies.orient.core.index.sbtree.local.OSBTree.validatedPut(OSBTree.java:261)
      at com.orientechnologies.orient.core.index.engine.OSBTreeIndexEngine.validatedPut(OSBTreeIndexEngine.java:169)
      at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.doValidatedPutIndexValue(OAbstractPaginatedStorage.java:2519)
      at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.validatedPutIndexValue(OAbstractPaginatedStorage.java:2488)
      at com.orientechnologies.orient.core.index.OIndexUnique.put(OIndexUnique.java:82)
      at com.orientechnologies.orient.core.index.OIndexUnique.put(OIndexUnique.java:35)
      at com.orientechnologies.orient.core.index.OIndexAbstract.putInSnapshot(OIndexAbstract.java:956)
      at com.orientechnologies.orient.core.index.OIndexAbstract.applyIndexTxEntry(OIndexAbstract.java:790)
      at com.orientechnologies.orient.core.index.OIndexAbstract.addTxOperation(OIndexAbstract.java:762)
      at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.commitIndexes(OAbstractPaginatedStorage.java:1904)
      at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.commit(OAbstractPaginatedStorage.java:1861)
      at com.orientechnologies.orient.core.tx.OTransactionOptimistic.doCommit(OTransactionOptimistic.java:541)
      at com.orientechnologies.orient.core.tx.OTransactionOptimistic.commit(OTransactionOptimistic.java:99)
      at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:2908)
      at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:2870)
      at org.sonatype.nexus.orient.transaction.OrientTransaction.commit(OrientTransaction.java:74)
      at org.sonatype.nexus.transaction.TransactionalWrapper.proceedWithTransaction(TransactionalWrapper.java:68)
      at org.sonatype.nexus.transaction.Operations.proceedWithTransaction(Operations.java:232)
      at org.sonatype.nexus.transaction.Operations.transactional(Operations.java:223)
      at org.sonatype.nexus.transaction.Operations.run(Operations.java:175)
      at org.sonatype.nexus.orient.transaction.OrientOperations.run(OrientOperations.java:62)
      at org.sonatype.nexus.internal.selector.OrientSelectorConfigurationStore.create(OrientSelectorConfigurationStore.java:103)
      at org.sonatype.nexus.common.stateguard.MethodInvocationAction.run(MethodInvocationAction.java:39)
      at org.sonatype.nexus.common.stateguard.StateGuard$GuardImpl.run(StateGuard.java:272)
      at org.sonatype.nexus.common.stateguard.GuardedInterceptor.invoke(GuardedInterceptor.java:53)
      at org.sonatype.nexus.internal.selector.SelectorManagerImpl.create(SelectorManagerImpl.java:164)

      Dev Notes
      Probably we just need to check if the selector already exists in the db so we can return the expected error.

        Attachments

          Activity

            People

            Assignee:
            tahir.awan Tahir Awan
            Reporter:
            rseddon Rich Seddon
            Last Updated By:
            Michael Oliverio Michael Oliverio
            Team:
            NXRM - Neo
            Votes:
            5 Vote for this issue
            Watchers:
            12 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Date of First Response:

                tigCommentSecurity.panel-title