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

[Bug] (alpha) 500 internal server error (pydantic ValidationError) #1111

Closed
sargunv opened this issue Aug 23, 2024 · 3 comments
Closed

[Bug] (alpha) 500 internal server error (pydantic ValidationError) #1111

sargunv opened this issue Aug 23, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@sargunv
Copy link

sargunv commented Aug 23, 2024

RomM version
1.5.0 alpha 1

Describe the bug
When I load the Dreamcast platform (in which I have some multi disc games), I get "Couldn't fetch roms for platform ID 15: AxiosError: Request failed with status code 500" in the UI. The 500 is on /api/roms?platform_id=15&search_term=&order_by=name&order_dir=asc. Checking the log, I see a pydantic ValidationErrror:

pydantic_core._pydantic_core.ValidationError: 5 validation errors for SimpleRomSchema
files.0
  Input should be a valid dictionary [type=dict_type, input_value='D2 (USA).m3u', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/dict_type
files.1
  Input should be a valid dictionary [type=dict_type, input_value='D2 (USA) (Disc 4).chd', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/dict_type
files.2
  Input should be a valid dictionary [type=dict_type, input_value='D2 (USA) (Disc 3).chd', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/dict_type
files.3
  Input should be a valid dictionary [type=dict_type, input_value='D2 (USA) (Disc 2).chd', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/dict_type
files.4
  Input should be a valid dictionary [type=dict_type, input_value='D2 (USA) (Disc 1).chd', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/dict_type

To Reproduce

Add a multi disc game to a platform in v3.4.0, like the following:

CleanShot 2024-08-22 at 23 36 39@2x

Scan the platform.

Update to v3.5.0 alpha 1.

Open that platform in the Romm frontend.

Expected behavior

The platform's game list should load without error.

Screenshots
CleanShot 2024-08-22 at 23 31 14@2x

Desktop (please complete the following information):

  • OS: macOS
  • Browser Chrome
  • Version 127.0.6533.120

Additional Context

_romm_logs (1).txt

@sargunv sargunv added the bug Something isn't working label Aug 23, 2024
@sargunv
Copy link
Author

sargunv commented Aug 23, 2024

Some detail on the cause: the files column on the roms table used to be a list[str], but now it's a list[RomFile]. However, in my database, ~47 rom records still have strings instead of objects:

select json_type(json_extract(files, "$[0]")) as type, count(*)
from roms
group by type
type count(*)
null 1608
OBJECT 565
STRING 47

I'm not sure why 47 records failed to convert to object, or how to force them to convert (short of manually updating the db records)

@sargunv
Copy link
Author

sargunv commented Aug 23, 2024

Triggering a new scan of the affected platforms fixes the bad data and resolves the error.

select json_type(json_extract(files, "$[0]")) as type, count(*)
from roms
group by type
type count(*)
null 1282
OBJECT 938

Eventually, after re-scanning all platforms, null came down to zero too:

type count(*)
OBJECT 2220

@gantoine
Copy link
Member

Thanks for investigating this! I was about to add that triggering any scan will fix the files array, and that the latest alpha release should trigger a scan on startup (through a migration). In any case we'll add a note in the release notes to manually run a scan if it doesn't trigger automatically on upgrade.

BTW if you're interested in testing future pre-releases, there's a closed Alpha Testers group on our Discord. We'd love to have you join it! https://discord.gg/PDGPX6tZ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants