Skip to content

fix(testdb): correct YAML noise assertion decode type assertion (#3872)#4162

Open
SAY-5 wants to merge 2 commits into
keploy:mainfrom
SAY-5:fix/issue-3872-noise-decode-type-assertion
Open

fix(testdb): correct YAML noise assertion decode type assertion (#3872)#4162
SAY-5 wants to merge 2 commits into
keploy:mainfrom
SAY-5:fix/issue-3872-noise-decode-type-assertion

Conversation

@SAY-5

@SAY-5 SAY-5 commented Apr 30, 2026

Copy link
Copy Markdown

Fixes #3872. pkg/platform/yaml/testdb/util.go decoded the noise assertion sub-map by asserting:

noiseMap, ok := raw.(map[models.AssertionType]interface{})

YAML never decodes a sub-map into that custom-typed key, yaml.v3 produces map[string]interface{}, yaml.v2 produces map[interface{}]interface{}. The assertion always failed, the Debug log fired, and tc.Noise stayed empty. Users' noise configurations were silently dropped during test replay.

Change

Extracted a populateNoise(raw, noise) helper that:

  • Accepts map[string]interface{} (yaml.v3), map[interface{}]interface{} (yaml.v2), and map[string][]string (programmatic round-trips).
  • Iterates entries, initialising noise[field] = []string{} (preserves the existing 'empty key still present' behaviour) and accepting both []interface{} and []string for the inner values.

Both the HTTP and gRPC branches in DecodeTestcase now delegate to this helper, eliminating the duplicate buggy block.

Test plan

  • go build ./pkg/platform/yaml/testdb/..., clean
  • go vet ./pkg/platform/yaml/testdb/..., clean
  • go test ./pkg/platform/yaml/testdb/..., all existing tests pass
  • New noise_decode_test.go covers all three input shapes (yaml.v3 map, yaml.v2 map, concrete map[string][]string)
  • Pre-fix the existing pattern raw.(map[models.AssertionType]interface{}) returns ok == false for every yaml-decoded shape (asserted by tracing the test inputs)

Customer-data hygiene

No real recordings or customer data introduced. Test inputs use synthetic header names (X-Request-ID, Cookie) and field paths (body.timestamp).

@SAY-5 SAY-5 requested a review from gouravkrosx as a code owner April 30, 2026 18:14
@github-actions

github-actions Bot commented Apr 30, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@github-actions

Copy link
Copy Markdown

The CLA check failed. Please ensure you have:

  • Signed the CLA by commenting 'I have read the CLA Document and I hereby sign the CLA.'
  • Used the correct email address in your commits (matches the one you used to sign the CLA).

After fixing these issues, comment 'recheck' to trigger the workflow again.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you and congratulations 🎉 for opening your very first pull request in keploy

@SAY-5

SAY-5 commented Apr 30, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA.

@SAY-5

SAY-5 commented Apr 30, 2026

Copy link
Copy Markdown
Author

recheck

slayerjain added a commit that referenced this pull request Apr 30, 2026
Signed-off-by: SAY-5 <say.apm35@gmail.com>
@SAY-5 SAY-5 force-pushed the fix/issue-3872-noise-decode-type-assertion branch from aa71df1 to 4f3f094 Compare May 11, 2026 21:06
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

1 participant