Skip to content

Conversation

@romancepenguin
Copy link

Redis only allows the use of positive integers.

@changeset-bot
Copy link

changeset-bot bot commented Sep 26, 2025

⚠️ No Changeset found

Latest commit: b3d1488

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Owner

@stipsan stipsan left a comment

Choose a reason for hiding this comment

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

Tests are failing :O

@stipsan stipsan requested a review from Copilot September 26, 2025 12:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds validation to the expire command to ensure it only accepts positive integers for the seconds parameter, aligning with Redis behavior.

  • Added input validation to reject non-integer or negative values
  • Throws appropriate Redis-compatible error message for invalid inputs

import { emitNotification } from '../keyspace-notifications'

export function expire(key, seconds) {
if (!Number.isInteger(seconds) || seconds < 0) {
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

The validation should check for seconds <= 0 instead of seconds < 0 since Redis doesn't allow zero as a valid expire value (zero would mean immediate expiration, which Redis handles differently with DEL command).

Suggested change
if (!Number.isInteger(seconds) || seconds < 0) {
if (!Number.isInteger(seconds) || seconds <= 0) {

Copilot uses AI. Check for mistakes.
Redis only allows the use of positive integers.
@romancepenguin
Copy link
Author

Tests are failing :O

Some type is coming in through the string.
So I check integer after casting the number.

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.

2 participants