ubiquibot / comment-incentives

0 stars 10 forks source link

fix: external repositories link crash #16

Closed gentlementlegen closed 4 months ago

gentlementlegen commented 4 months ago

Resolves #15

0x4007 commented 4 months ago

Do you have a link to a good GitHub Actions run?

gentlementlegen commented 4 months ago

It doesn't look like any functional changes. Just debugging related.

The issue was that the check for remote repositories was done with the wrong variables here

    const organization = parts[parts.length - 4];
    const repository = parts[parts.length - 3];
    const currentOrganization = parts[parts.length - 4];
    const currentRepository = parts[parts.length - 3];
    const number = Number(parts[parts.length - 1]);
    const href = `https://github.com${relativeHref}`;

    if (`${organization}/${repository}` !== `${owner}/${repository}`) {
    if (`${currentOrganization}/${currentRepository}` !== `${owner}/${repository}`) {

it was shadowing the repository variable, so the test was true event if in the case of the crash we had ubiquity/devpool-directory-bounties against ubiquity/devpool-directory.

The way I tested it is locally, through a personal GitHub token, it works fine without needing to put it in GitHub action. You can test with the payload that was fed into the Action that crashed:

{
  inputs: {
    collaborators: '["pavlovcik","sergfeldman","molecula451","0xCapitalist","gitcoindev","Draeieg","wannacfuture","rndquu","diamondnegroni","whilefoo","0x4007"]',
    eventName: 'issues.closed',
    installationId: '35097154',
    issueNumber: '14',
    issueOwner: 'ubiquity',
    issueRepository: 'devpool-directory-bounties'
  }
}

I added the output of the error in the log for convenience, because it would give a good hint on what went wrong.

0x4007 commented 4 months ago

Okay your approach makes sense. I can try merging and re-running the action with the same input to verify that this indeed works.

0x4007 commented 4 months ago

I see now. On GitHub mobile it doesn't show the full file. I had to manually load the beginning lines to see that the parameters are indeed being shadowed. Nice debugging!