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

Pydantic validation errors when selecting mirror region on master #3081

Closed
correctmost opened this issue Jan 5, 2025 · 13 comments · Fixed by #3104
Closed

Pydantic validation errors when selecting mirror region on master #3081

correctmost opened this issue Jan 5, 2025 · 13 comments · Fixed by #3104

Comments

@correctmost
Copy link
Contributor

Steps to reproduce

  • Run archinstall from master
  • Select "Mirrors"
  • Select "Mirror region"
    • Notice the regions list is empty
  • Press the down key to trigger a RecursionError

Logs

Error while fetching mirror list: 1044 validation errors for MirrorStatusListV3
urls.0.score
  Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=1.8560666648693478, input_type=float]
    For further information visit https://errors.pydantic.dev/2.10/v/int_from_float
urls.1.score
  Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=4.47652977626422, input_type=float]
    For further information visit https://errors.pydantic.dev/2.10/v/int_from_float
urls.2.score
  Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=3.004490779181443, input_type=float]
    For further information visit https://errors.pydantic.dev/2.10/v/int_from_float
...

Bisection

Commit 1d278f8 seems to have introduced the validation errors. (I cannot reproduce the errors with the previous commit, 8f2bf2b.)

@svartkanin
Copy link
Collaborator

@correctmost I couldn't reproduce the recursion part, but this PR #3104 might fix the problem as it will return on an empty mirror option list.

@correctmost
Copy link
Contributor Author

correctmost commented Jan 11, 2025

Hmm, I was still able to reproduce the empty regions list and the RecursionError with the ISO from PR #3104:

empty_mirror_regions

I will try to get more debugging info.

@svartkanin
Copy link
Collaborator

Would you know if your list is loaded from remote or local? Could you try running it with --offline and see if that result in the same?

@correctmost
Copy link
Contributor Author

Here are two recent install logs from the PR ISO:

@svartkanin
Copy link
Collaborator

Unable to fetch mirror list remotely, falling back to local mirror list

Okay let me try to debug it

@svartkanin
Copy link
Collaborator

@correctmost would you be able to share your local /etc/pacman.d/mirrorlist I suspect there's something wrong with the parsing

@correctmost
Copy link
Contributor Author

Here's the mirror list from the VM I'm testing with:

################################################################################
################# Arch Linux mirrorlist generated by Reflector #################
################################################################################

# With:       reflector @/etc/xdg/reflector/reflector.conf
# When:       2025-01-11 05:37:57 UTC
# From:       https://archlinux.org/mirrors/status/json/
# Retrieved:  2025-01-11 05:37:17 UTC
# Last Check: 2025-01-11 05:17:17 UTC

Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch
Server = https://america.mirror.pkgbuild.com/$repo/os/$arch
Server = https://london.mirror.pkgbuild.com/$repo/os/$arch
Server = https://at.arch.mirror.kescher.at/$repo/os/$arch
Server = https://de.arch.mirror.kescher.at/$repo/os/$arch
Server = https://mirror.moson.org/arch/$repo/os/$arch
Server = https://mirror.theo546.fr/archlinux/$repo/os/$arch
Server = https://mirror.pseudoform.org/$repo/os/$arch
Server = https://arch.phinau.de/$repo/os/$arch
Server = https://mirror.cyberbits.eu/archlinux/$repo/os/$arch
Server = https://mirror.kumi.systems/archlinux/$repo/os/$arch
Server = https://europe.mirror.pkgbuild.com/$repo/os/$arch
Server = https://md.mirrors.hacktegic.com/archlinux/$repo/os/$arch
Server = https://archlinux.thaller.ws/$repo/os/$arch
Server = https://mirror.ufscar.br/archlinux/$repo/os/$arch
Server = https://sydney.mirror.pkgbuild.com/$repo/os/$arch
Server = https://repo.jing.rocks/archlinux/$repo/os/$arch
Server = https://asia.mirror.pkgbuild.com/$repo/os/$arch
Server = https://mirror.telepoint.bg/archlinux/$repo/os/$arch
Server = https://mirrors.neusoft.edu.cn/archlinux/$repo/os/$arch

@svartkanin
Copy link
Collaborator

Ahh yeah there's no country on the top so the region name is empty, the parser assumes

## COUNTRY
Server = ...

and then uses COUNTRY as the region name in the selection menu... maybe just calling it "Local" as a default should work

@correctmost
Copy link
Contributor Author

Related discussion: #3013

@svartkanin
Copy link
Collaborator

@correctmost pushed an update to the PR that should fix the parsing now, also addressed the bug mentioned in #3013

@correctmost
Copy link
Contributor Author

Here are my findings after retesting:

  1. archinstall and archinstall --offline now show a "Local" region for me
  2. There are still Pydantic validation errors in install.log
  3. The server_url change should be reverted now that Use removeprefix/removesuffix instead of incorrect lstrip/rstrip calls #3109 has landed. Combining both changes will cause double slashes:

double_slashes

@svartkanin
Copy link
Collaborator

I assume point 2 will be fixed by #3079 ?
Reverted the server_url change which has removed the double slash now

@correctmost
Copy link
Contributor Author

I assume point 2 will be fixed by #3079 ?

Hmm, my change from #3079 didn't fix the issue. This change makes all of the regions appear again, though:

diff --git a/archinstall/lib/models/mirrors.py b/archinstall/lib/models/mirrors.py
index f899bc5e..2205b10f 100644
--- a/archinstall/lib/models/mirrors.py
+++ b/archinstall/lib/models/mirrors.py
@@ -29,7 +29,7 @@ class MirrorStatusEntryV3(BaseModel):
        duration_avg: float | None = None
        duration_stddev: float | None = None
        completion_pct: float | None = None
-       score: int | None = None
+       score: float | None = None
        _latency: float | None = None
        _speed: float | None = None
        _hostname: str | None = None

It seems like the ideal fix is to indicate that the incoming JSON has float data and the validated data has int data. I don't know the best way to accomplish that with Pydantic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants