-
Notifications
You must be signed in to change notification settings - Fork 135
chore: Allow only positive integers in expire #1360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
stipsan
left a comment
There was a problem hiding this 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
There was a problem hiding this 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
src/commands/expire.js
Outdated
| import { emitNotification } from '../keyspace-notifications' | ||
|
|
||
| export function expire(key, seconds) { | ||
| if (!Number.isInteger(seconds) || seconds < 0) { |
Copilot
AI
Sep 26, 2025
There was a problem hiding this comment.
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).
| if (!Number.isInteger(seconds) || seconds < 0) { | |
| if (!Number.isInteger(seconds) || seconds <= 0) { |
Redis only allows the use of positive integers.
5ed1507 to
b3d1488
Compare
Some type is coming in through the string. |
Redis only allows the use of positive integers.