Fix /v1/internal/backfill-stale 500 from mixed-type Map#10
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 27 minutes and 25 seconds.Comment |
Summary
PR #9 deployed and the backfill endpoint immediately 500'd:
```
java.lang.IllegalStateException: Serializing collections of different element
types is not yet supported. Selected serializers: [kotlin.Int, kotlin.Boolean]
at io.ktor.serialization.kotlinx.SerializerLookupKt.elementSerializer
...
at zed.rainxch.githubstore.routes.InternalRoutesKt$internalRoutes$2$2.invokeSuspend(InternalRoutes.kt:526)
```
Root cause: `mapOf("scheduled" to N, "started" to true)` is a `Map<String, Any>` and kotlinx.serialization can't infer a single element serializer when values span `Int` + `Boolean` + `String`. Same for the no-candidates and conflict branches.
Fix
Replace the three response `mapOf` calls with a typed `@Serializable BackfillResponse` DTO:
```kotlin
@serializable
data class BackfillResponse(
val scheduled: Int,
val started: Boolean,
val message: String? = null,
)
```
Three callers:
Test plan
```
docker exec github-store-backend-app-1 curl -sS -X POST \
-H "X-Admin-Token: $ADMIN_TOKEN" \
http://localhost:8080/v1/internal/backfill-stale
```
Expect: 202 + `{"scheduled": , "started": true, "message": null}`. Watch `docker logs` for "Backfill done: ok=N gone=M ...".