Skip to content

Guard HMGET against empty payload keys in GetWorkflowInstanceHistory - #487

Merged
cschleiden merged 3 commits into
cschleiden:mainfrom
DerkSchooltink:fix/hmget-empty-payloads
Aug 10, 2026
Merged

Guard HMGET against empty payload keys in GetWorkflowInstanceHistory#487
cschleiden merged 3 commits into
cschleiden:mainfrom
DerkSchooltink:fix/hmget-empty-payloads

Conversation

@DerkSchooltink

Copy link
Copy Markdown
Contributor

Problem

(*redisBackend).GetWorkflowInstanceHistory calls HMGET key <fields...> with an empty field list when an instance's history stream has no events, which Redis rejects:

ERR wrong number of arguments for 'hmget' command

This surfaces as reading payloads: ... from GetWorkflowInstanceHistory for instances whose history stream is empty (e.g. an orphaned/pruned instance, or a read where lastSequenceID is at/after the newest event so XRANGE returns nothing).

Fix

getWorkflowInstanceState in backend/redis/workflow.go already guards the identical payload fetch with if len(payloadKeys) > 0. This applies the same guard in backend/redis/instance.go. When there are no events there are no payloads to fetch, so the block is simply skipped and an empty history is returned.

@DerkSchooltink
DerkSchooltink force-pushed the fix/hmget-empty-payloads branch from 12c0521 to acf11e1 Compare July 2, 2026 11:29
@DerkSchooltink

Copy link
Copy Markdown
Contributor Author

Funnily enough this is already fixed in my Valkey PR: https://github.com/cschleiden/go-workflows/pull/460/changes#diff-33c2b06ea8a250f39db361963182b32d9f40e48dc055d65daa85e0e4597df261R103

@cschleiden let me know if you need more information, this is a bug I found in production, if you need specific logs or failure conditions, hit me up. :)

When an instance's history stream is empty, payloadKeys is empty and
HMGET is called with no fields, which Redis rejects with 'ERR wrong
number of arguments for hmget'. Guard the payload fetch with
len(payloadKeys) > 0, mirroring the existing guard in workflow.go.
@DerkSchooltink
DerkSchooltink force-pushed the fix/hmget-empty-payloads branch from acf11e1 to a3737a8 Compare July 2, 2026 11:44
DerkSchooltink and others added 2 commits July 21, 2026 13:10
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@cschleiden
cschleiden merged commit 48e8119 into cschleiden:main Aug 10, 2026
5 checks passed
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