Skip to content

fix: handle null Predis set members#204

Merged
LKaemmerling merged 2 commits into
PromPHP:mainfrom
simPod:fix-predis-smembers-null
May 28, 2026
Merged

fix: handle null Predis set members#204
LKaemmerling merged 2 commits into
PromPHP:mainfrom
simPod:fix-predis-smembers-null

Conversation

@simPod
Copy link
Copy Markdown
Contributor

@simPod simPod commented May 28, 2026

Summary

  • Normalize null Predis SMEMBERS responses to an empty array
  • Predis can return null from SMEMBERS at runtime despite its declared array return type
  • Add a regression test for null SMEMBERS results

It actually happened even though contract does not allow it.

image

Signed-off-by: Simon Podlipsky <simon@podlipsky.net>
@simPod simPod force-pushed the fix-predis-smembers-null branch from 83ba1bf to a50d112 Compare May 28, 2026 06:04
@simPod simPod requested a review from Copilot May 28, 2026 07:12
Copy link
Copy Markdown

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 makes the Predis Redis client wrapper more defensive by normalizing unexpected null responses from SMEMBERS to the adapter contract’s expected empty array behavior.

Changes:

  • Coalesces Predis\Client::smembers() null results to [].
  • Adds a regression test covering null SMEMBERS responses.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Prometheus/Storage/RedisClients/Predis.php Normalizes null smembers responses to an empty array.
tests/Test/Prometheus/Storage/PredisTest.php Adds a unit regression test for null SMEMBERS results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@LKaemmerling LKaemmerling left a comment

Choose a reason for hiding this comment

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

Good catch! Thank you

@LKaemmerling LKaemmerling enabled auto-merge (squash) May 28, 2026 07:39
@LKaemmerling LKaemmerling merged commit 527d20c into PromPHP:main May 28, 2026
20 checks passed
@simPod simPod deleted the fix-predis-smembers-null branch May 28, 2026 07:43
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.

3 participants