Skip to content

fix(server): reject a retention.conversationsDays that isn't above 0 - #456

Merged
anurag629 merged 2 commits into
codercops:devfrom
prakashNalla:fix/retention-days
Oct 29, 2026
Merged

anurag629 merged 2 commits into
codercops:devfrom
prakashNalla:fix/retention-days

Conversation

@prakashNalla

Copy link
Copy Markdown
Collaborator

What does this change?

purge() deletes conversations last updated before now - conversationsDays * DAY_MS, so retention.conversationsDays set to 0 deleted every conversation, and a negative number put the cutoff in the future and did the same. createChatHandler now throws when it's set to anything that isn't a finite number above 0, next to the maxRequests check. Leaving it out still means 30 days. Patch changeset for @chatcops/server.

Closes #451

How I tested this

Added cases to packages/server/tests/storage-config.test.ts for 0, -1, NaN and Infinity. All four fail without the change.

  • pnpm -r build and pnpm -r typecheck: pass
  • pnpm test: 2013 tests passed (65 skipped)
  • pnpm lint: passes

AI assistance

Claude helped me w/ understand the issue

Checklist

  • This PR targets dev
  • I was assigned the linked issue
  • pnpm -r build, pnpm test and pnpm -r typecheck pass locally
  • Tests added or updated where it makes sense
  • For a bug fix: the new test fails without my change
  • Changeset added (pnpm changeset) if this changes core, widget or server
  • Docs updated if behavior or options changed

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @prakashNalla, this is right, and the check sits where it should, next to maxRequests. I merged it with current dev, which now has #462 (session tokens required by default): build, typecheck, test:coverage, lint (same as dev) and api:check pass, and the four cases fail with the old handler.ts. They still pass on dev because the retention check runs before the session check. That's fine, and adding allowAnonymous: true to that test's config later would keep it independent of the order. Merging once CI is green.

@anurag629
anurag629 merged commit 6e88477 into codercops:dev Oct 29, 2026
8 of 10 checks passed
@anurag629 anurag629 added the hacktoberfest-accepted PR counts for Hacktoberfest label Oct 29, 2026
@anurag629

Copy link
Copy Markdown
Member

Merged, thanks @prakashNalla.

@anurag629 anurag629 mentioned this pull request Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted PR counts for Hacktoberfest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server: retention.conversationsDays: 0 makes purge() delete every conversation

2 participants