ARK-Builders / ARK-Builders/Navigator

Half-written metadata

Open
#370 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
16
Forks
14
PR merge metrics
No merged PRs in 30d

Description

We need atomic writing for metadata and other computed values.
- https://github.com/ARK-Builders/arklib/issues/48

```
kotlinx.serialization.json.internal.JsonDecodingException: Cannot begin reading element, unexpected token: 10 at path: $
JSON input:
at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24)
at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32)
at kotlinx.serialization.json.internal.AbstractJsonLexer.fail(AbstractJsonLexer.kt:528)
at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$default(AbstractJsonLexer.kt:526)
at kotlinx.serialization.json.internal.JsonTreeReader.read(JsonTreeReader.kt:104)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeJsonElement(StreamingJsonDecoder.kt:33)
at kotlinx.serialization.json.JsonElementSerializer.deserialize(JsonElementSerializers.kt:51)
at kotlinx.serialization.json.JsonElementSerializer.deserialize(JsonElementSerializers.kt:27)
at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:59)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:38)
at kotlinx.serialization.json.Json.decodeFromString(Json.kt:100)
at kotlinx.serialization.json.Json.parseToJsonElement(Json.kt:128)
at space.taran.arklib.domain.meta.MetadataStorage.valueFromBinary(MetadataStorage.kt:35)
at space.taran.arklib.domain.storage.FolderStorage$readFromDisk$jobs$2$1.invokeSuspend(FolderStorage.kt:94)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@8ef4f0d, Dispatchers.IO]
```

Contributor guide

Open the contributing guide

Research direction

Start at MetadataStorage.valueFromBinary in MetadataStorage.kt:35 and FolderStorage.readFromDisk in FolderStorage.kt:94, then inspect the code that writes metadata and computed values. Reproduce or test an interrupted write and verify that atomic persistence prevents the shown JsonDecodingException while keeping metadata readable.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.