spotify-web-api-kotlin
spotify-web-api-kotlin copied to clipboard
getAlbumTracks 400 Error when called often
Describe the bug
when I call api.albums.getAlbumTracks()
for a lot of albums (e.g. 40 or 80), I get Received Status Code 400. Error cause: malformed request sent
for some requests
To Reproduce
val api = spotifyAppApi()
val tracks = albumIds.flatMap { albumId ->
api.albums.getAlbumTracks(albumId).getAllItemsNotNull()
}
create albumIds list from this file: albumIds.txt
Desktop:
- OS: Windows
- Kotlin/JVM
- Project with Java 17
- Kotlin 1.6
Does this occur for the same ids every time?
no every time other ids and sometimes it doesn't happen and sometimes e.g 5 request fail (avg. 2-6 requests fail)
I have not reproduced this bug.
Apologies, that was a typo. I have not been able to reproduce this bug on kotlin 1.6.20, version 3.8.6 @michaeldomanek after several thousands of requests. My code:
suspend fun main() = runBlocking {
val api = spotifyAppApi("", "").build()
api.spotifyApiOptions.enableDebugMode = true
api.spotifyApiOptions.useCache = false
val albumIds = File("${System.getProperty("user.home")}/Downloads/albumIds.txt").readText()
.replace("[\\[\\]]".toRegex(), "")
.split(", ")
while (true) {
val tracks = albumIds.map { albumId ->
async {
api.albums.getAlbumTracks(albumId).getAllItemsNotNull()
}
}.awaitAll()
println(tracks)
}
}
Can you give me more information around this behavior? Is there a particular exception or stacktrace you can share
Hello @adamint thanks for looking into it. This is my Stacktrace: Stacktrace.txt I edited my comment because yesterday I thought it was a Java 17 problem and changing sdk solved the problem, but today it happened with other Java versions too.
I created a new sample project to test it: kotlin-gradle-example The Stacktrace is from here if you want to look at it.
Hi @michaeldomanek, I'm still unable to reproduce this with the given sample, on various JDKs (8, 11, 17). You reproduced it in this sample project? Do you have the debug console logs listing the request (from enableDebugMode)
No additional info was provided, closing