I found a bug in Atlassian Connect Express Sequelize storage adapter, how do I report it?

Upsert in the storage adapter’s set function always inserts a new record instead of updating the old record. This breaks reinstallation:

 async set(key, value, clientKey) {
    const settings = await connectionPromise;

    const [result] = await settings.upsert({
      key,
      clientKey,
      val: value
    });

    return getAsObject(result.get("val"));

I was able to correct it by modifying set in the source:

async set(key, value, clientKey) {
    const settings = await connectionPromise;

    let obj = await settings.findOne({ where: {clientKey} });
    if (obj) {
      obj.update({val: value});
    } else {
      obj = await settings.create({
        key,
        clientKey,
        val: value
      });
    }

    return getAsObject(obj.get("val"));
  }

I know my fix is naïve so we are planning on exploring the other officially supported storage options.

I wasn’t able to report it in the bitbucket/jira for ACE, so I was hoping I could raise the issue here.

Env: We are using MySQL for the database. We are in dev env mode. We are creating a jira-cloud app.

Thanks,
Liam

1 Like

Thank you Liam. We hit this too (sequelize/postgresql) and your fix worked for us.

Best way is to fork the repo and then submit a pull request back. I’ve had a couple of items fixed that way.

/Daniel

Thanks for reporting.

When creating the pull request to fix, please see the previous pull request that caused the problem:
https://bitbucket.org/atlassian/atlassian-connect-express/pull-requests/212#chg-lib/store/sequelize.js

Fixing this issue is not a high priority for me (I’m not on the project at present), and realistically I can’t see myself making time to fix it in the near future based on my circumstances.

I wouldn’t trust the fix I wrote as I do not understand the edge cases that may arise, nor am I able to provide test cases for verifying correct behavior of the program. An even bigger part is that if upsert worked as intended this fix would be unnecessary.

@LiamGryphon Thanks for reporting the issue! And for doing the PR. :smiley:

@ndao Is there a fix for this bug coming? I’m asking because I would like to update to ACE v. 6.XX.

@ndao I am hitting this issue too. It sounds like the OP does not have the resources to submit a PR. It would be ideal if Atlassian itself could prioritize and provide this fix, given that this effectively prevents the most recent publicly-available version of Connect from functioning with anything other than the toy in-memory database.

I’ll create a fix and release a new version soon.

v6.2.1 has been released:

to fix the bug:
https://bitbucket.org/atlassian/atlassian-connect-express/pull-requests/220/acejs-160-revert-sequelize-upsert

2 Likes

@ndao Thank you for your fast action on this.