fix: correct noise assertion type assertion in YAML decode (#3872)#3945
Open
DhineshPonnarasan wants to merge 1 commit intokeploy:mainfrom
Open
fix: correct noise assertion type assertion in YAML decode (#3872)#3945DhineshPonnarasan wants to merge 1 commit intokeploy:mainfrom
DhineshPonnarasan wants to merge 1 commit intokeploy:mainfrom
Conversation
When decoding test cases from YAML, noise assertions were silently
dropped because the type assertion used map[models.AssertionType]interface{}
but YAML always deserializes map keys as plain strings (map[string]interface{}).
Since models.AssertionType is a named string type, the assertion always
failed and tc.Noise was never populated.
Fix both the HTTP and gRPC decode branches to use map[string]interface{}
and remove the now-unnecessary string(kt) cast.
Closes keploy#3872
Signed-off-by: Dhinesh Ponnarasan <[email protected]>
e937fb6 to
171b734
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes YAML decoding of noise assertions so tc.Noise is correctly populated when loading test cases, preventing silent loss of noise configuration during replay/matching.
Changes:
- Update noise assertion type assertion to
map[string]interface{}in both HTTP and gRPC decode branches. - Remove unnecessary key casting (
string(kt)) by iterating over string keys directly. - Adjust warning text to reflect the corrected expected runtime type.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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:
Describe the changes
Fixed a silent data loss bug where noise assertions were always dropped when loading test cases from YAML files.
Root cause:
YAML deserialization always produces map[string]interface{} for maps. The decode code was asserting raw.(map[models.AssertionType]interface{}) — even though models.AssertionType is defined as type AssertionType string, Go treats them as distinct types, so the assertion always failed silently and tc.Noise was never populated.
Fix:
Changed the type assertion to map[string]interface{} (the actual runtime type) in both the HTTP and gRPC decode branches, and removed the now-unnecessary string(kt) cast.
Closes: #3872
@gouravkrosx , @Sarthak160 ,
Please review the changes and let me know if any further modifications are required. Thank you!