Skip to content

fix: correct noise assertion type assertion in YAML decode (#3872)#3945

Open
DhineshPonnarasan wants to merge 1 commit intokeploy:mainfrom
DhineshPonnarasan:fix/issue-3872-noise-assertion-type-decode
Open

fix: correct noise assertion type assertion in YAML decode (#3872)#3945
DhineshPonnarasan wants to merge 1 commit intokeploy:mainfrom
DhineshPonnarasan:fix/issue-3872-noise-assertion-type-decode

Conversation

@DhineshPonnarasan
Copy link
Copy Markdown

@DhineshPonnarasan DhineshPonnarasan commented Mar 20, 2026

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!

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]>
@DhineshPonnarasan DhineshPonnarasan force-pushed the fix/issue-3872-noise-assertion-type-decode branch from e937fb6 to 171b734 Compare March 20, 2026 06:11
@DhineshPonnarasan DhineshPonnarasan marked this pull request as ready for review March 20, 2026 06:12
Copilot AI review requested due to automatic review settings March 20, 2026 06:12
Copy link
Copy Markdown
Contributor

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

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.

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.

[bug]: Noise assertions silently dropped during YAML decode due to incorrect type assertion

2 participants