Repository navigation
fix(time-series): return a null sample from TS.MGET for an empty series - #3530
Merged
nkaradzhov merged 1 commit intoOct 23, 2026
Merged
nkaradzhov merged 1 commit into
nkaradzhov merged 1 commit into
Conversation
For a series that exists but has no samples yet, TS.MGET sends an empty
sample. transformSampleReply destructured it anyway, so mGet(),
mGetWithLabels() and mGetSelectedLabels() returned
{ timestamp: undefined, value: NaN } on RESP2 and both fields undefined on
RESP3, which reads as a measurement. TS.GET on the same key returns null.
Add transformNullableSampleReply, which returns null for an empty sample,
as TS.GET does, and use it on the MGET path only. transformSampleReply
stays non-null, so RANGE, MRANGE and READ keep their types.
Fixes redis#3528
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #3528
For a series that exists but has no samples yet, TS.MGET sends an empty sample (
[]), andtransformSampleReplydestructures[timestamp, value]from it anyway. Sots.mGet(),ts.mGetWithLabels()andts.mGetSelectedLabels()return a sample with an undefined timestamp for that key. On master, redis 8.10.2, with one empty and one written series under the same label:and with this branch:
TS.GET already returns
nullfor the same empty reply, so the MGET commands now do the same, as agreed in the issue.Added
transformNullableSampleReplynext totransformSampleReplyin helpers.ts. It returnsnullfor an empty sample and otherwise callstransformSampleReply. MGET andcreateTransformMGetLabelsReply(MGET_WITHLABELS, reused by MGET_SELECTED_LABELS) use it. The declaredsampletype on the three commands is now{ timestamp, value } | null, the same as TS.GET's.transformSampleReplyandtransformSamplesReplydon't change, so RANGE, REVRANGE, READ and the MRANGE variants keep their types.Added a RESP2/RESP3 test in each of MGET.spec.ts, MGET_WITHLABELS.spec.ts and MGET_SELECTED_LABELS.spec.ts: a labelled series with no samples, and
sampleshould be null. All 6 fail on master.npm run build && npm testpasses (time-series 196, client 3541), lint is clean.Checklist
npm testpass with this change (including linting)?Note
Low Risk
Localized reply-transform change with tests; no auth or persistence impact, and RANGE/MGET sample paths stay on the non-nullable transformer.
Overview
TS.MGET family commands now return
sample: nullwhen a matched time series exists but has no data points, instead of a broken object withundefinedtimestamp andNaN/undefinedvalue.A new
transformNullableSampleReplyhelper treats an empty[]sample from Redis asnulland otherwise uses the existing sample transformer.mGet,mGetWithLabels, andmGetSelectedLabelswire this in for RESP2 and RESP3, matchingTS.GETbehavior (fixes #3528). RANGE/MRANGE-style commands are unchanged.Integration tests cover an empty labelled series for both RESP versions on all three MGET variants.
Reviewed by Cursor Bugbot for commit 73a80a4. Bugbot is set up for automated code reviews on this repo. Configure here.