Skip to content

fix(sessions): skip session rows without an id in the sweep - #1645

Merged
rohitg00 merged 2 commits into
rohitg00:mainfrom
dmazhukov:fix/1644-session-sweep-idless-rows
Nov 3, 2026
Merged

rohitg00 merged 2 commits into
rohitg00:mainfrom
dmazhukov:fix/1644-session-sweep-idless-rows

Conversation

@dmazhukov

@dmazhukov dmazhukov commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

mem::session-sweep now skips stale active rows in mem:sessions that have no non-empty string id, so one such row no longer fails every hourly run. Fixes #1644.

isStaleActive did not look at id, so the sweep sent state::get with no key for such a row. The engine rejected it, the row was counted in failed, and every sweep returned success: false, because the row could never be abandoned. The guard is the one api::sessions and memory_sessions already apply.

Not covered: the id-less rows stay in the store, and mem::evict and replace imports still address rows by id; repairing them needs the store key, which kv.list does not return.

Summary by CodeRabbit

  • Bug Fixes
    • Session cleanup now skips stale sessions with missing, null, numeric, or empty IDs, avoiding invalid lookups. Stale sessions with valid IDs continue to be processed, and the cleanup can complete successfully without reporting failures when invalid-ID rows are skipped.

isStaleActive did not look at id, so a stale active row without a string
id reached kv.get(KV.sessions, candidate.id). The engine rejects a
state::get with no key, the row was counted as failed, and since the sweep
can never abandon it, every hourly run reported success: false.

The sweep now skips rows without a non-empty string id, the same check the
sessions endpoint and memory_sessions apply.

Signed-off-by: Dmitrii Zhukov <dmitry0983@gmail.com>
@vercel

vercel Bot commented Oct 30, 2026

Copy link
Copy Markdown

@dmazhukov is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4c503f0d-8fb3-4f4f-b634-d6defa9dde83
Commits

Reviewing files that changed from the base of the PR and between 12ba293 and 53ca6d7.

Files selected for processing: 1
  • test/session-sweep.test.ts
Files skipped from review as they are similar to previous changes: 1
  • test/session-sweep.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The session sweep skips stale active rows without a non-empty string ID. A test verifies that invalid IDs do not reach kv.get and that valid stale sessions are still abandoned.

Changes: Session sweep ID validation

Layer / File(s) Summary
Validate stale session IDs
src/functions/session-sweep.ts, test/session-sweep.test.ts
isStaleActive rejects rows with missing, non-string, or empty IDs. The test verifies that unusable rows remain active, valid stale sessions are abandoned, and the sweep reports no failures.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • #1644: The change adds the requested guard that skips stale rows without a non-empty string ID.

Suggested reviewers: rohitg00

Merge Risk: Minimal · up to 53ca6

The sweep now skips malformed session rows while continuing to abandon valid stale sessions. No actionable merge-blocking issue remains; merge after normal checks pass.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: skipping session rows without a valid id during the sweep.
Linked Issues check Passed Issue #1644 requires the sweep to skip stale active rows without a non-empty string id, abandon other stale sessions, and report success: true with failed: 0 when no other failures occur. `src/f…
Out of Scope Changes check Passed The changes are limited to the required mem::session-sweep guard and its automated test. The test verifies that unusable rows remain active. No unrelated eviction, import repair, or store cleanup be…
Full details: Linked Issues check

Explanation

Issue #1644 requires the sweep to skip stale active rows without a non-empty string id, abandon other stale sessions, and report success: true with failed: 0 when no other failures occur. src/functions/session-sweep.ts now rejects missing, non-string, and empty IDs before stale-session processing. The added test covers these row shapes, verifies that the valid stale session is abandoned, and verifies success: true with failed: 0.

Full details: Out of Scope Changes check

Explanation

The changes are limited to the required mem::session-sweep guard and its automated test. The test verifies that unusable rows remain active. No unrelated eviction, import repair, or store cleanup behavior was added.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • 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.

Share

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Devin Review

Comment thread test/session-sweep.test.ts Resolved
coderabbitai[bot]

This comment was marked as resolved.

The override matches mockKV's own get signature and the typed sdk.trigger needs no cast, so the new test follows the no-any rule in CONTRIBUTING.

Signed-off-by: Dmitrii Zhukov <dmitry0983@gmail.com>
@rohitg00
rohitg00 merged commit 7c73b9c into rohitg00:main Nov 3, 2026
12 of 13 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.

mem::session-sweep fails every run when mem:sessions holds a row without an id

2 participants