Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Achievements metrics shows (Unexpected Error) #1479

Closed
orsnaro opened this issue Jul 11, 2023 Discussed in #1478 · 17 comments · Fixed by #1487
Closed

Achievements metrics shows (Unexpected Error) #1479

orsnaro opened this issue Jul 11, 2023 Discussed in #1478 · 17 comments · Fixed by #1487

Comments

@orsnaro
Copy link

orsnaro commented Jul 11, 2023

Discussed in #1478

Originally posted by orsnaro July 11, 2023
image

metrics code in my metrics_action.yml

@LuanRoger
Copy link

Same here.
The log does not help so much, it's just this that shows up:

...
  metrics/compute/plugins > achievements > setup found (?)
  metrics/compute/plugins > achievements > setup found (?)
  metrics/compute/plugins > achievements > setup found (?)
...

Usign the debug: yes flag.

This was thrown soo many times, probably because the auto-retry. I cancel the action execution after 7 min.

@redlinejoes
Copy link

I also see the issue: "Unexpected error"
I see this in the achievements workflow

  [
    {
      name: 'achievements',
      result: {
        error: {
          message: 'Unexpected error',
          instance: 'Failed to initiate total for achievement plugin'
        }
      }
    }
  ]

@TonyCrane
Copy link
Contributor

GitHub have added a home page to GitHub Search, so metrics can't get total repository/user/issue number from https://github.com/search.

And the query string can't be empty, so maybe we can try searching created:>2007, although this may be not exact, but at least it works.

      for (let i = 0; (i < 100) && ((!total.users) || (!total.repositories)); i++) {
        const page = await browser.newPage()
        await page.goto("https://github.com/search?q=+created%3A%3E2007")
        const totalres = await page.evaluate(() => [...[...document.querySelectorAll("h2")].filter(node => /Filter by/.test(node.innerText)).shift()?.nextSibling?.innerText.trim().matchAll(/(?<type>Repositories|Users|Issues)\n(?<count>.*?)M/g) ?? []]) ?? null
        for (const result of totalres) {
          const type = result[1]?.toLowerCase()
          console.debug(`metrics/compute/plugins > achievements > setup found ${type ?? "(?)"}`)
          const count = result[2] ?? ""
          if ((count !== "") && (!total[type])) {
            total[type] = Number(count) * 10e5
            console.debug(`metrics/compute/plugins > achievements > set total.${type} to ${total[type]}`)
          }
        }
        await page.close()
        await imports.wait(10 * Math.random())
      }

njzjz added a commit to deepmodeling/.github that referenced this issue Jul 17, 2023
@X-itachi-X
Copy link

GitHub have added a home page to GitHub Search, so metrics can't get total repository/user/issue number from https://github.com/search.

And the query string can't be empty, so maybe we can try searching created:>2007, although this may be not exact, but at least it works.

      for (let i = 0; (i < 100) && ((!total.users) || (!total.repositories)); i++) {
        const page = await browser.newPage()
        await page.goto("https://github.com/search?q=+created%3A%3E2007")
        const totalres = await page.evaluate(() => [...[...document.querySelectorAll("h2")].filter(node => /Filter by/.test(node.innerText)).shift()?.nextSibling?.innerText.trim().matchAll(/(?<type>Repositories|Users|Issues)\n(?<count>.*?)M/g) ?? []]) ?? null
        for (const result of totalres) {
          const type = result[1]?.toLowerCase()
          console.debug(`metrics/compute/plugins > achievements > setup found ${type ?? "(?)"}`)
          const count = result[2] ?? ""
          if ((count !== "") && (!total[type])) {
            total[type] = Number(count) * 10e5
            console.debug(`metrics/compute/plugins > achievements > set total.${type} to ${total[type]}`)
          }
        }
        await page.close()
        await imports.wait(10 * Math.random())
      }

can you explain please what I have to do to make it work?

@orsnaro
Copy link
Author

orsnaro commented Jul 18, 2023

GitHub have added a home page to GitHub Search, so metrics can't get total repository/user/issue number from https://github.com/search.
And the query string can't be empty, so maybe we can try searching created:>2007, although this may be not exact, but at least it works.

      for (let i = 0; (i < 100) && ((!total.users) || (!total.repositories)); i++) {
        const page = await browser.newPage()
        await page.goto("https://github.com/search?q=+created%3A%3E2007")
        const totalres = await page.evaluate(() => [...[...document.querySelectorAll("h2")].filter(node => /Filter by/.test(node.innerText)).shift()?.nextSibling?.innerText.trim().matchAll(/(?<type>Repositories|Users|Issues)\n(?<count>.*?)M/g) ?? []]) ?? null
        for (const result of totalres) {
          const type = result[1]?.toLowerCase()
          console.debug(`metrics/compute/plugins > achievements > setup found ${type ?? "(?)"}`)
          const count = result[2] ?? ""
          if ((count !== "") && (!total[type])) {
            total[type] = Number(count) * 10e5
            console.debug(`metrics/compute/plugins > achievements > set total.${type} to ${total[type]}`)
          }
        }
        await page.close()
        await imports.wait(10 * Math.random())
      }

can you explain please what I have to do to make it work?

@X-itachi-X probably says to edit the http here index.mjs : line 85

redlinejoes added a commit to redlinejoes/metrics that referenced this issue Jul 18, 2023
redlinejoes added a commit to redlinejoes/metrics that referenced this issue Jul 18, 2023
@JohnyP36
Copy link

JohnyP36 commented Jul 19, 2023

I have the same problem and disabling the workflow and then enabling it again does not work.

The error in the action is as follows:

Can someone see what's wrong here and explain this?

details
Rendering                                                       │  
1 error(s) occurred
  [
  Status                                                          │ complete
    {
  MIME type                                                       │ image/svg+xml
      name: 'achievements',
      result: {
  ────────────────────────────────────────────────────────────────────────────────────────
  Saving                                                          │  
  Output condition                                                │ always
  Save to /metrics_renders/.github/src/metrics.plugin.achievements.compact.svg │ ok
  Output action                                                   │ commit
        error: {
          message: 'Unexpected error',
          instance: 'Failed to initiate total for achievement plugin'
        }
      }
    }
  ]
Current render sha                                              │ fa44788002fed81464296f2c6203928f8fd7648d
Commit to branch main                                           │ (no changes)

@redlinejoes
Copy link

Your question has been answered already, but you have to read the full contents of the issue. I will copy the direct link to make it easier for you to read.

#1479 (comment)

@JohnyP36
Copy link

Your question has been answered already, but you have to read the full contents of the issue. I will copy the direct link to make it easier for you to read.

#1479 (comment)

Thanks. But this means the problem is not on my side but with metrics? If yes, thank you for the fix in advance.

@redlinejoes
Copy link

redlinejoes commented Jul 19, 2023

GitHub have added a home page to GitHub Search, so metrics can't get total repository/user/issue number from https://github.com/search.
And the query string can't be empty, so maybe we can try searching created:>2007, although this may be not exact, but at least it works.

      for (let i = 0; (i < 100) && ((!total.users) || (!total.repositories)); i++) {
        const page = await browser.newPage()
        await page.goto("https://github.com/search?q=+created%3A%3E2007")
        const totalres = await page.evaluate(() => [...[...document.querySelectorAll("h2")].filter(node => /Filter by/.test(node.innerText)).shift()?.nextSibling?.innerText.trim().matchAll(/(?<type>Repositories|Users|Issues)\n(?<count>.*?)M/g) ?? []]) ?? null
        for (const result of totalres) {
          const type = result[1]?.toLowerCase()
          console.debug(`metrics/compute/plugins > achievements > setup found ${type ?? "(?)"}`)
          const count = result[2] ?? ""
          if ((count !== "") && (!total[type])) {
            total[type] = Number(count) * 10e5
            console.debug(`metrics/compute/plugins > achievements > set total.${type} to ${total[type]}`)
          }
        }
        await page.close()
        await imports.wait(10 * Math.random())
      }

can you explain please what I have to do to make it work?

@X-itachi-X probably says to edit the http here index.mjs : line 85

It is more than line#85.
I tried just to replace line#85, and it failed because you need to replace all the different code and then it will work.
See my new profile page, for example https://github.com/redlinejoes

@redlinejoes
Copy link

GitHub have added a home page to GitHub Search, so metrics can't get total repository/user/issue number from https://github.com/search.

And the query string can't be empty, so maybe we can try searching created:>2007, although this may be not exact, but at least it works.

      for (let i = 0; (i < 100) && ((!total.users) || (!total.repositories)); i++) {
        const page = await browser.newPage()
        await page.goto("https://github.com/search?q=+created%3A%3E2007")
        const totalres = await page.evaluate(() => [...[...document.querySelectorAll("h2")].filter(node => /Filter by/.test(node.innerText)).shift()?.nextSibling?.innerText.trim().matchAll(/(?<type>Repositories|Users|Issues)\n(?<count>.*?)M/g) ?? []]) ?? null
        for (const result of totalres) {
          const type = result[1]?.toLowerCase()
          console.debug(`metrics/compute/plugins > achievements > setup found ${type ?? "(?)"}`)
          const count = result[2] ?? ""
          if ((count !== "") && (!total[type])) {
            total[type] = Number(count) * 10e5
            console.debug(`metrics/compute/plugins > achievements > set total.${type} to ${total[type]}`)
          }
        }
        await page.close()
        await imports.wait(10 * Math.random())
      }

I have tested and implemented your code, and it works as expected. Thank you for your contribution!

@TonyCrane
Copy link
Contributor

Yes, you can view the complete changes in TonyCrane@46f3272.

But seems this repo haven't updated for a few months, and my last pull request is ignored and closed by robot, so I haven't open a PR for this (also I don't think my solution is the best).

But I think we should repair this? So what do you think @lowlighter ?

@lowlighter
Copy link
Owner

@TonyCrane I tested your patch locally and it works as expected. I think the workaround is good enough for now so I merged it into master 👍

I guess now we could use the Search API directly by passing your query into it and be more reliable and faster, instead of using puppeteer as it could break again in a future redesign

@obfuscatedgenerated
Copy link

obfuscatedgenerated commented Jul 31, 2023

I'm fairly certain this bug is causing Actions builds to hang for 10 minutes or more looking at the timing of this issue and my logs:
logs showing long builds since a little over 3 weeks ago

It's probably a good idea to get the fix into a published GitHub release as soon as possible so it doesn't burn through everyone's actions minutes (since most use lowlighter/metrics@latest as advised in the setup)

@redlinejoes
Copy link

I'm fairly certain this bug is causing Actions builds to hang for 10 minutes or more looking at the timing of this issue and my logs:
logs showing long builds since a little over 3 weeks ago

It's probably a good idea to get the fix into a published GitHub release as soon as possible so it doesn't burn through everyone's actions minutes (since most use lowlighter/metrics@latest as advised in the setup)

My actions jumped to over 11 minutes because of this issue. If you implement the changes outlined in this thread it will run faster again. Make sure to change the year to capture pre-2007 content if you have any. That is referenced in this thread too.

@AjaniBilby
Copy link

This issue is closed and it looks like a PR has been merged solving this issue...
But I'm still getting it 🤔

@RSickenberg
Copy link
Contributor

Still the issue with the latest version.

image

@TonyCrane
Copy link
Contributor

After this pr is merged, there is no new release, so @latest is still an old version. If you want to use the repaired version, you need to use @master.

chriswells0 added a commit to chriswells0/chriswells0 that referenced this issue Aug 2, 2023
Includes a fix for "unexpected error" in metrics:

lowlighter/metrics#1479
Apocryphon-X added a commit to Apocryphon-X/Apocryphon-X that referenced this issue Aug 9, 2023
Fixes the achievements "Unexpected Error"
lowlighter/metrics#1479
Downside: Instead of using a @stable I needed to move into @master temporarily
@github-actions github-actions bot locked and limited conversation to collaborators Aug 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants