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]: Impossible to get a list of files where there are folders #45

Closed
2 tasks done
denchic45 opened this issue Jan 16, 2023 · 2 comments
Closed
2 tasks done

[Bug]: Impossible to get a list of files where there are folders #45

denchic45 opened this issue Jan 16, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@denchic45
Copy link

General Info

  • I installed the latest version of Supabase-Kt
  • I checked for similar bug report

What happened? (include your code)

I'm trying to get a list of files in a folder, but because the folder has a null id, the resulting json cannot be serialized successfully

    val items: List<BucketItem> = storage["main"].list("Folders").onEach {
        println(it.name)
    }

Dashboard:
image

Postman:
image

But the BucketApi class requires a non-null id

@Serializable
data class BucketItem(
    val name: String,
    val id: String,
    @SerialName("updated_at")
    val updatedAt: Instant,
    @SerialName("created_at")
    val createdAt: Instant,
    @SerialName("last_accessed_at")
    val lastAccessedAt: Instant,
    val metadata: JsonObject
)

Platform(s)

Desktop

Relevant log output

Unexpected JSON token at offset 25: Expected string literal but 'null' literal was found at path: $[0].id
Use 'coerceInputValues = true' in 'Json {}` builder to coerce nulls to default values.
JSON input: [{"name":"Folder 1","id":null,"updated_at":null,"create.....
io.ktor.serialization.JsonConvertException: Unexpected JSON token at offset 25: Expected string literal but 'null' literal was found at path: $[0].id
Use 'coerceInputValues = true' in 'Json {}` builder to coerce nulls to default values.
JSON input: [{"name":"Folder 1","id":null,"updated_at":null,"create.....
	(Coroutine boundary)
	at io.ktor.client.plugins.HttpCallValidator$Companion$install$2.invokeSuspend(HttpCallValidator.kt:138)
	at io.ktor.client.call.HttpClientCall.bodyNullable(HttpClientCall.kt:88)
	at io.github.jan.supabase.storage.BucketApiImpl.list(BucketApi.kt:312)
	at com.studiversity.feature.course.submission.SubmissionRoutingKtTest$testAttachments$1.invokeSuspend(SubmissionRoutingKtTest.kt:35)
Caused by: io.ktor.serialization.JsonConvertException: Unexpected JSON token at offset 25: Expected string literal but 'null' literal was found at path: $[0].id
Use 'coerceInputValues = true' in 'Json {}` builder to coerce nulls to default values.
JSON input: [{"name":"Folder 1","id":null,"updated_at":null,"create.....
	(Coroutine boundary)
	at io.ktor.client.plugins.HttpCallValidator$Companion$install$2.invokeSuspend(HttpCallValidator.kt:138)
Caused by: io.ktor.serialization.JsonConvertException: Unexpected JSON token at offset 25: Expected string literal but 'null' literal was found at path: $[0].id
Use 'coerceInputValues = true' in 'Json {}` builder to coerce nulls to default values.
JSON input: [{"name":"Folder 1","id":null,"updated_at":null,"create.....
	at app//io.ktor.serialization.kotlinx.KotlinxSerializationConverter.deserialize(KotlinxSerializationConverter.kt:79)
	at app//io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1$2.emit(Emitters.kt:224)
	at app//kotlinx.coroutines.flow.FlowKt__BuildersKt$asFlow$$inlined$unsafeFlow$3.collect(SafeCollector.common.kt:115)
	at app//io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1.collect(SafeCollector.common.kt:113)
	at app//kotlinx.coroutines.flow.FlowKt__ReduceKt.firstOrNull(Reduce.kt:243)
	at app//kotlinx.coroutines.flow.FlowKt.firstOrNull(Unknown Source)
	at app//io.ktor.serialization.ContentConverterKt.deserialize(ContentConverter.kt:128)
	at app//io.ktor.client.plugins.contentnegotiation.ContentNegotiation.convertResponse$ktor_client_content_negotiation(ContentNegotiation.kt:185)
	at app//io.ktor.client.plugins.contentnegotiation.ContentNegotiation$Plugin$install$2.invokeSuspend(ContentNegotiation.kt:210)
	at app//io.ktor.client.plugins.contentnegotiation.ContentNegotiation$Plugin$install$2.invoke(ContentNegotiation.kt)
	at app//io.ktor.client.plugins.contentnegotiation.ContentNegotiation$Plugin$install$2.invoke(ContentNegotiation.kt)
	at app//io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:120)
	at app//io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:78)
	at app//io.ktor.client.HttpClient$4.invokeSuspend(HttpClient.kt:177)
	at app//io.ktor.client.HttpClient$4.invoke(HttpClient.kt)
	at app//io.ktor.client.HttpClient$4.invoke(HttpClient.kt)
	at app//io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:120)
	at app//io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:78)
	at app//io.ktor.util.pipeline.SuspendFunctionGun.proceedWith(SuspendFunctionGun.kt:88)
	at app//io.ktor.client.plugins.HttpCallValidator$Companion$install$2.invokeSuspend(HttpCallValidator.kt:138)
	at app//io.ktor.client.plugins.HttpCallValidator$Companion$install$2.invoke(HttpCallValidator.kt)
	at app//io.ktor.client.plugins.HttpCallValidator$Companion$install$2.invoke(HttpCallValidator.kt)
	at app//io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:120)
	at app//io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:78)
	at app//io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:98)
	at app//io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77)
	at app//io.ktor.client.call.HttpClientCall.bodyNullable(HttpClientCall.kt:88)
	at app//io.github.jan.supabase.storage.BucketApiImpl.list(BucketApi.kt:396)
	at app//io.github.jan.supabase.storage.BucketApiImpl$list$1.invokeSuspend(BucketApi.kt)
	(Coroutine boundary)
	at io.ktor.client.HttpClient$4.invokeSuspend(HttpClient.kt:177)
	at io.ktor.client.plugins.HttpCallValidator$Companion$install$2.invokeSuspend(HttpCallValidator.kt:138)
	at io.ktor.client.call.HttpClientCall.bodyNullable(HttpClientCall.kt:88)
	at io.github.jan.supabase.storage.BucketApiImpl.list(BucketApi.kt:312)
@denchic45 denchic45 added the bug Something isn't working label Jan 16, 2023
@jan-tennert
Copy link
Collaborator

Publishing a patch when I'm back home!

@jan-tennert
Copy link
Collaborator

Should be fixed in 0.7.5. Let me know if there are any issues!

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