Enhance KV existence checks for better reliability and bugfix on creating MCI.#2125
Merged
cb-github-robot merged 2 commits intocloud-barista:mainfrom Aug 28, 2025
Merged
Conversation
- Use exists flag instead of comparing empty KeyValue struct - Add proper checks for key existence in kvstore operations - Improve error handling when keys are not found - Fix inconsistent key validation across all modules
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request enhances key-value store operations by replacing unreliable struct comparisons with explicit existence checks using a boolean flag. The primary motivation is to fix issues where structs containing maps cannot be directly compared using the pattern if keyValue != (kvstore.KeyValue{}), which could lead to runtime panics.
- Modifies kvstore interface methods to return an additional
existsboolean parameter - Updates all calling code to use the explicit existence flag instead of empty struct comparisons
- Uses
_placeholder for cases where the existence check isn't immediately needed
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/kvstore/kvstore/kvstore.go | Updates kvstore interface to return existence boolean for Get methods |
| src/kvstore/etcd/etcd.go | Implements the new interface with proper existence checks for etcd backend |
| src/core/resource/*.go | Updates resource management code to use new existence checks |
| src/core/infra/*.go | Updates infrastructure code to use new existence checks |
| src/core/common/*.go | Updates common utilities to use new existence checks |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Member
|
/approve |
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.
This pull request introduces a more robust method for checking key existence in our kvstore operations by using an explicit
existsflag.Key Changes
mapcannot be directly compared like this patternif keyValue != (kvstore.KeyValue{})_placeholder where full refactoring wasn't immediately feasible, marking areas for future improvementExample Change
Benefits
Test