Skip to content

Fix /v1/internal/backfill-stale 500 from mixed-type Map#10

Merged
rainxchzed merged 1 commit intomainfrom
fix-backfill-response
May 4, 2026
Merged

Fix /v1/internal/backfill-stale 500 from mixed-type Map#10
rainxchzed merged 1 commit intomainfrom
fix-backfill-response

Conversation

@rainxchzed
Copy link
Copy Markdown
Member

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:

  • 202 `Accepted` after a successful schedule: `scheduled=N, started=true`
  • 200 when nothing to backfill: `scheduled=0, started=false, message="no stale rows"`
  • 409 when another backfill is already running: `scheduled=0, started=false, message="backfill_already_running"`

Test plan

  • `./gradlew test` -- green.
  • After deploy, retry the backfill via SSH:
    ```
    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 ...".

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

Warning

Rate limit exceeded

@rainxchzed has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 25 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90174ab1-52f1-49dd-99d7-977e0caca1d8

📥 Commits

Reviewing files that changed from the base of the PR and between 8e24fa6 and ed31274.

📒 Files selected for processing (1)
  • src/main/kotlin/zed/rainxch/githubstore/routes/InternalRoutes.kt
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-backfill-response

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 27 minutes and 25 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@rainxchzed rainxchzed merged commit 69a8043 into main May 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant