Repository navigation
fix: complete only the open entry for a reused requestId - #250
Conversation
Bridges that pass a callback name as the id had every past entry rewritten by each response. Closes #248.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Response target selection and persistence dari-runtime/src/main/kotlin/com/easyhooon/dari/data/MessageRepository.kt, dari-runtime/src/main/kotlin/com/easyhooon/dari/data/local/MessageDao.kt, dari-runtime/src/test/kotlin/com/easyhooon/dari/data/MessageRepositoryReusedIdTest.kt |
MessageRepository selects the latest matching IN_PROGRESS entry per direction, or the latest entry without a response timestamp if none is IN_PROGRESS. It emits updates for selected entries and queues database updates by persisted ID. Tests compare in-memory entries with persisted results across reused-ID scenarios. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)
sequenceDiagram
participant MessageRepository
participant MessageDao
participant RoomDatabase
MessageRepository->>MessageRepository: Select response targets and resolve persisted IDs
MessageRepository->>MessageDao: Queue response updates by entry ID
MessageDao->>RoomDatabase: Update row by ID
Possibly related issues
- Support bridge layouts that don't fit the requestId/parameter model #249: The PR addresses the reused-ID behavior described in row 1. The issue’s other bridge-layout cases are outside this change.
Merge Risk: 
Minimal · up to 3b963
-
The response-matching change has no identified issue that needs resolution before merging. Concurrent calls sharing an ID remain an acknowledged limitation.
Pre-merge checks: 
3 · 
2
-
Failed checks: 2 warnings Passed checks: 3 passed-
Full details: Out of Scope Changes check
-
Explanation
The changes stay within the reused-requestId response handling in issue
#248. The repository selection logic, primary-key DAO update, lock-ordered writes, and focused tests support correct response targeting and persistence. No unrelated product or public API changes are shown.
-
Full details: Linked Issues check
-
Explanation
Issue
#248requires a response to update only the latest matchingIN_PROGRESSentry. If no matching entry isIN_PROGRESS, the response must be dropped.MessageRepository.responseTargets()instead falls back tomatches.lastOrNull { responseTimestamp == null }. The new fire-and-forget test confirms this behavior, so the implementation does not meet the linked issue requirement.Resolution
Remove the no-response fallback from
responseTargets()so it returns no target when no matching entry isIN_PROGRESS. Update the affected fire-and-forget test and behavior to match issue#248.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Comment @coderabbitai help to get the list of available commands.
Close #248
Problem
A response completed every entry that shared its requestId, tag and direction. Bridges that pass a callback name as the id (
getToken("onTokenResult")twice) had all earlier entries rewritten with the latest response, status and timestamp.Cause
MessageRepository.update()transformed every matching entry in memory, andMessageDao.updateByRequestIddid the same in SQL.Fix
IN_PROGRESSmatch, or else the latest match with no response yet (keeps recording late responses for fire-and-forget entries). With neither, it updates nothing, so a late or duplicate response no longer rewrites a completed call.MessageDao.updateResponse, replacingupdateByRequestId). A temp id resolves to its DB id throughwireIds.addEntry's insert andupdate's write are now queued while holdinglock, so a response arriving on another thread can't queue its DB update before the insert and get dropped.Public API is unchanged; the DAO is internal and the Room schema is the same.
Verification
MessageRepositoryReusedIdTest(Robolectric, in-memory Room), checked in memory and in the DB: serial calls keep their own responses; an unanswered request doesn't take the next response; a late duplicate leaves completed calls alone; a fire-and-forget entry still records its response; a row left open by a previous repository instance doesn't take the new call's response.main../gradlew :dari-runtime:testDebugUnitTestpasses (28 tests), and the pre-pushdetekt+ktlintCheckpass. androidTest was not run.Summary by CodeRabbit