mirror of
https://github.com/gabehf/Koito.git
synced 2026-04-22 20:11:50 -07:00
Fix Maloja importer resilience: nil MBZ client, null album, error handling
Root cause of the panic at ~1,693 items: importers created
`&mbz.MusicBrainzClient{}` (nil requestQueue) instead of using the
engine's properly initialized client. When any code path called an MBZ
method, it panicked on the nil channel.
Changes:
- Pass engine's MBZ client to Maloja and Spotify importers
- Change MalojaTrack.Album to pointer type to handle null album JSON
- Continue on error instead of aborting the entire import
- Accept both Maloja export formats ("scrobbles" and "list" keys)
- Extract per-file import into importFile() with its own defer/recover
- Add progress logging every 500 items
Test fixtures:
- maloja_import_null_album_test.json (null album, valid album, empty artists)
- maloja_api_format_test.json (API "list" format)
New tests: TestImportMaloja_NullAlbum, TestImportMaloja_ApiFormat
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0ec7b458cc
commit
c2d393aa03
6 changed files with 224 additions and 55 deletions
41
test_assets/maloja_api_format_test.json
Normal file
41
test_assets/maloja_api_format_test.json
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"status": "ok",
|
||||
"list": [
|
||||
{
|
||||
"time": 1746434410,
|
||||
"track": {
|
||||
"artists": [
|
||||
"API Format Artist"
|
||||
],
|
||||
"title": "API Format Track",
|
||||
"album": {
|
||||
"artists": [
|
||||
"API Format Artist"
|
||||
],
|
||||
"albumtitle": "API Format Album"
|
||||
},
|
||||
"length": null
|
||||
},
|
||||
"duration": null,
|
||||
"origin": "client:default"
|
||||
},
|
||||
{
|
||||
"time": 1746434682,
|
||||
"track": {
|
||||
"artists": [
|
||||
"API Format Artist"
|
||||
],
|
||||
"title": "API Format Track 2",
|
||||
"album": {
|
||||
"artists": [
|
||||
"API Format Artist"
|
||||
],
|
||||
"albumtitle": "API Format Album"
|
||||
},
|
||||
"length": null
|
||||
},
|
||||
"duration": null,
|
||||
"origin": "client:default"
|
||||
}
|
||||
]
|
||||
}
|
||||
52
test_assets/maloja_import_null_album_test.json
Normal file
52
test_assets/maloja_import_null_album_test.json
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"maloja": {
|
||||
"export_time": 1748738994
|
||||
},
|
||||
"scrobbles": [
|
||||
{
|
||||
"time": 1746434410,
|
||||
"track": {
|
||||
"artists": [
|
||||
"Null Album Artist"
|
||||
],
|
||||
"title": "Track With Null Album",
|
||||
"album": null,
|
||||
"length": null
|
||||
},
|
||||
"duration": null,
|
||||
"origin": "client:default"
|
||||
},
|
||||
{
|
||||
"time": 1746434682,
|
||||
"track": {
|
||||
"artists": [
|
||||
"Valid Album Artist"
|
||||
],
|
||||
"title": "Track With Valid Album",
|
||||
"album": {
|
||||
"artists": [
|
||||
"Valid Album Artist"
|
||||
],
|
||||
"albumtitle": "My Great Album"
|
||||
},
|
||||
"length": null
|
||||
},
|
||||
"duration": null,
|
||||
"origin": "client:default"
|
||||
},
|
||||
{
|
||||
"time": 1746434900,
|
||||
"track": {
|
||||
"artists": [],
|
||||
"title": "Track With Empty Artists",
|
||||
"album": {
|
||||
"artists": [],
|
||||
"albumtitle": "Some Album"
|
||||
},
|
||||
"length": null
|
||||
},
|
||||
"duration": null,
|
||||
"origin": "client:default"
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue