LinkUp error using script

Below is the code am using to link up data between two tables. This was working fine until I did the same on another base and it threw this error. Any help is appreciated!

error: TypeError: Cannot read property ‘table2_id’ of undefined
at e.value
at eval , line: 24
at Array.forEach
at Proxy.main , line: 17

const mainTable = 'Interactions';
const mainView = 'Default View';
const mainLinkCol = 'Buyer Master';

const secTable = 'Buyer Master';
const secView = 'Default View';
const secLinkCol = 'Interactions';

const mainLinkId = base.getColumnLinkId(mainTable, mainLinkCol);
output.text(mainLinkId);

const rows = base.getRows(mainTable, mainView);
rows.slice(0, 1).forEach(row => {
  if (row.Mobile && row.Name) {
    const querySet = base.filter(secTable, secView, `Mobile = ${row.Mobile} and Name = "${row.Name}"`);
    const linkedRow = querySet.first();
    if (linkedRow) {
      const linkedRowId = linkedRow._id;
      if (row[mainLinkCol].length === 0) {
        base.addLink(mainLinkId, mainTable, secTable, row._id, linkedRowId);
      }
    }
  }
});

Hi, welcome to the SeaTable Forum.

If this script is working well in another base, it should work in this base, too.
Currently there’s a known issue, that in certain circumstances, the base.addLink doesn’t work immediately after you have created a new base. The solution to this issue is simple: add a link manually, and then delete this link. Now the script should work.
We are working on this issue.

Let me know if this helps!