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

Hacs tries to downgrade component to beta version #2233

Closed
6 tasks done
edenhaus opened this issue Oct 6, 2021 · 8 comments
Closed
6 tasks done

Hacs tries to downgrade component to beta version #2233

edenhaus opened this issue Oct 6, 2021 · 8 comments

Comments

@edenhaus
Copy link

edenhaus commented Oct 6, 2021

System Health details

System Health

version core-2021.9.7
installation_type Home Assistant Container
dev false
hassio false
docker true
user root
virtualenv false
python_version 3.9.7
os_name Linux
os_version 5.4.0-88-generic
arch x86_64
timezone Europe/Rome
Home Assistant Community Store
GitHub API ok
Github API Calls Remaining 4747
Installed Version 1.15.2
Stage running
Available Repositories 882
Installed Repositories 16
Lovelace
dashboards 6
resources 10
views 16
mode storage

Checklist

Describe the issue

Hacs informs the user about an update, but in fact it's a downgrade as you can see in the screenshot.
grafik

I started my investigation at the manifest of both version, but they are set correctly. Also the tags are set correctly so it must be a bug in hacs.

During my investigation in the hacs code base (sorry I'm not familiar with the code) I found out, that the function custom_components.hacs.helpers.functions.information.get_releases is getting the releases via aiogithubapi.
The returned list from aiogithubapi.objects.repository.AIOGitHubAPIRepository.get_releases is not sorted correctly by semantic versioning.
On the specific example of "Deebot-for-Home-Assistant" the returned list included the version in the following order:

  • 3.1.4b3
  • 3.1.4b2
  • 3.2.0
  • 3.1.4b1

I think this is the problem as hacs probably checks only the first entry and shows an update notification if the version don't match.
Please correct me if I'm wrong but this is my assumption and I didn't checked it. (My not familiar with the code and it takes some time to find the correct information)

I had to release a quick bug fix so the update window is showing now the correct version, but if you open the "reinstall" dialog, you can still see that the version are ordered wrong.
grafik

Reproduction steps

  1. Open the install dialog of the integration "Deebot for Home Assistant" and toggle "Show beta versions"
    1a. If you have already selected or installed the integration please click on "Update Information" to fetch the latest information
  2. As you can in the screenshot above the releases are sorted in the wrong order

For Devs:

  1. Create a breakpoint in config.custom_components.hacs.helpers.functions.information.get_releases on Line 79
  2. Click again on "Update Informations"
  3. When the debugger stops at the break point, modify the releases variable by sorting the versions correctly
    [releases[0], releases[3], releases[1], releases[2], releases[4]]
  4. Reopen the "reinstall" dialog and you can see that the versions are sorted correctly

Debug logs

2021-10-06 14:41:58 DEBUG (MainThread) [custom_components.hacs] Running update for And3rsL/Deebot-for-Home-Assistant
2021-10-06 14:41:58 DEBUG (MainThread) [custom_components.hacs] <Integration And3rsL/Deebot-for-Home-Assistant> Getting repository information
2021-10-06 14:41:59 DEBUG (MainThread) [custom_components.hacs] <Integration And3rsL/Deebot-for-Home-Assistant> Running checks against 3.2.1
2021-10-06 14:42:00 DEBUG (MainThread) [custom_components.hacs] 'states' is undefined
2021-10-06 14:42:00 DEBUG (MainThread) [custom_components.hacs] Saving data
@edenhaus edenhaus added the issue:backend For issues with the backend/integration label Oct 6, 2021
@hacs-bot
Copy link

hacs-bot bot commented Oct 6, 2021

Make sure you have read the issue guidelines and that you filled out the entire template.

@edenhaus
Copy link
Author

edenhaus commented Oct 6, 2021

I submitted only the logs, which I think are relevant. If you need all of them please let me know.
Issue originally reported by @mrbungle64 via Discord to me.

Maybe it#s related to #2203

@edenhaus edenhaus changed the title Hacs tries to downgrade to beta version Hacs tries to downgrade component to beta version Oct 6, 2021
@ludeeus
Copy link
Member

ludeeus commented Oct 6, 2021

HACS should not do any sorting.
It should return the order that the GitHub API returns.
What does that say?

@ludeeus ludeeus removed the issue:backend For issues with the backend/integration label Oct 6, 2021
@edenhaus
Copy link
Author

edenhaus commented Oct 6, 2021

Then the question is why, is the aiogithuapi returning a wrong order?
When you go to https://github.com/And3rsL/Deebot-for-Home-Assistant/releases the order is correct.
As you also the maintainer of aiogithubapi maybe we should move the issue there.

@ludeeus
Copy link
Member

ludeeus commented Oct 6, 2021

https://api.github.com/repos/And3rsL/Deebot-for-Home-Assistant/releases is what the API returns, which shows aiogithuapi and HACS is returning exactly what it's supposed to be.

@edenhaus
Copy link
Author

edenhaus commented Oct 6, 2021

Oh sorry my fault. I checked it now :)

Do you know a way how I can specify the order on the repository? I think it would be great if user will always get the newest version and not a "random" sorted list

@ludeeus
Copy link
Member

ludeeus commented Oct 6, 2021

Until GitHub adds a sort param to https://docs.github.com/en/rest/reference/repos#list-releases I don't see that happening.
You most likely got in this situation because your releases target 2 different branches. master and the now-deleted refactor-events, it uses the time from the last commit in the target branch to determine the order.

@edenhaus
Copy link
Author

edenhaus commented Oct 6, 2021

Thanks for your help 😊
Than I will follow your release cycle on hacs and only release version on master without betas 😊

As always thanks for all your work here and on HA and a nice release party tonight 😂

@edenhaus edenhaus closed this as completed Oct 6, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants