Prevent commandstore cache poisoning when backend Get fails after UpdateStatus - #7231
Open
vanshika2720 wants to merge 3 commits into
Open
Prevent commandstore cache poisoning when backend Get fails after UpdateStatus#7231vanshika2720 wants to merge 3 commits into
vanshika2720 wants to merge 3 commits into
Conversation
✅ Deploy Preview for pipecd-site canceled.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the control-plane commandstore cache behavior so transient datastore read failures during UpdateCommandHandled don’t poison the Redis-backed cache and later break command-handling authorization paths.
Changes:
- Stop
UpdateCommandHandledfrom writing to cache when the post-UpdateStatusbackend.Getfails. - Add a defensive
nilguard tocommandCache.Putto prevent cachingnilas JSONnull. - Add regression tests for the failure path and the new cache guard.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/app/server/commandstore/store.go | Skips cache write when backend.Get fails after a successful status update. |
| pkg/app/server/commandstore/cache.go | Adds a defensive nil check in Put to prevent writing invalid cache payloads. |
| pkg/app/server/commandstore/store_test.go | Adds regression tests covering transient Get failure after UpdateStatus and subsequent GetCommand behavior. |
| pkg/app/server/commandstore/cache_test.go | Adds a unit test ensuring commandCache.Put rejects nil inputs. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ateStatus Signed-off-by: Vanshika <pahalvanshikaa@gmail.com>
Signed-off-by: Vanshika <pahalvanshikaa@gmail.com>
Signed-off-by: Vanshika <pahalvanshikaa@gmail.com>
vanshika2720
force-pushed
the
fix/commandstore-cache-poisoning
branch
from
August 26, 2026 16:42
47bc31d to
5116824
Compare
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.
What this PR does:
Prevents
commandstorefrom caching a nil command when the datastoreGetfails after a successful command status update. It also adds a defensive nil check in the cache and regression tests covering the failure path.Why we need it:
A transient
Getfailure could previously result innilbeing cached as JSONnull. On a later cache read, this could become a zero-valueCommandwith an emptyPipedId, causingReportCommandHandledto returnPermissionDeniedfor the legitimate piped.Which issue(s) this PR fixes:
Fixes #7230
Does this PR introduce a user-facing change: