Hook cannot be retrieved by key from RepositoryHookDao after creation

XMLWordPrintable

    • Type: Bug
    • Resolution: Low Engagement
    • Priority: Low
    • None
    • Affects Version/s: None
    • Component/s: None
    • Severity 3 - Minor
    • 0

      Summary

      After a hook has been created, RepositoryHookDao.findByKey(internalRepository, hookKey) returns null. However, RepositoryHookService.getById(hookId) returns the record.

      Environment

      • Tested against 5.1.6 + H2
      • Customer reports failures from 5.0 onwards (see Notes)

      Steps to Reproduce

      1. Create a hook through RepositoryHookDao.create()
      2. Retrieve it through RepositoryHookDao.findByKey(internalRepository, hookKey)

      Expected Results

      The created record is returned.

      Actual Results

      null is returned.

      Notes

      Originally asked in this Community post.

      We ran the plug-in of the customer and could reproduce the behaviour against 5.1.6 while debugging (breakpoint in RepositoryHookService.enable()):

      • RepositoryHookService.getById(hookId) returns record
      • RepositoryHookDao.findByKey(internalRepository, hookKey) returns null
      • RepositoryHookDao.findAll(internalRepository, new PageRequestImpl(0,200)) does not return the record

      However, when writing a test to validate:

              InternalRepository one = repositoryDao.loadById(1);
              String hookKey = "some.hook.key";
              String data = "{\"cloneType\":\"http\",\"ignoreCerts\":true,\"jenkinsBase\":\"http://localhost\"}";
              InternalRepositoryHook.Builder hookBuilder = new InternalRepositoryHook.Builder()
                      .hookKey(hookKey)
                      .repository(convertToInternalRepository(one))
                      .enabled(true);
              hookBuilder.settings(data);
      
              dao.create(hookBuilder.build());
              InternalRepositoryHook hook = dao.findByKey(one, hookKey);
              assertNotNull(hook);

      We could not reproduce the issue (above test passes). Still, we are confident this is a bug in Bitbucket Server.

      Workaround

      Not applicable.

              Assignee:
              Unassigned
              Reporter:
              Dick (Inactive)
              Votes:
              4 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: