Skip to content

chore: add omitempty to bson/json tags for FilterPolicy and TLSPrivat…#3972

Open
Yogeshjindal wants to merge 6 commits intomainfrom
chore/omitempty-bson-tags
Open

chore: add omitempty to bson/json tags for FilterPolicy and TLSPrivat…#3972
Yogeshjindal wants to merge 6 commits intomainfrom
chore/omitempty-bson-tags

Conversation

@Yogeshjindal
Copy link
Copy Markdown
Contributor

…eKeyPath

These fields serialize as empty strings in API responses when unset, causing test failures for the k8s-proxy config endpoint.

Describe the changes that are made

Links & References

Closes: #[issue number that will be closed through this PR]

  • NA (if very small change like typo, linting, etc.)

🔗 Related PRs

  • NA

🐞 Related Issues

  • NA

📄 Related Documents

  • NA

What type of PR is this? (check all applicable)

  • 📦 Chore
  • 🍕 Feature
  • 🐞 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🔁 CI
  • ⏩ Revert

Added e2e test pipeline?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

Added comments for hard-to-understand areas?

  • 👍 yes
  • 🙅 no, because the code is self-explanatory

Added to documentation?

  • 📜 README.md
  • 📓 Wiki
  • 🙅 no documentation needed

Are there any sample code or steps to test the changes?

  • 👍 yes, mentioned below
  • 🙅 no, because it is not needed

Self Review done?

  • ✅ yes
  • ❌ no, because I need help

Any relevant screenshots, recordings or logs?

  • NA

🧠 Semantics for PR Title & Branch Name

Please ensure your PR title and branch name follow the Keploy semantics:

📌 PR Semantics Guide
📌 Branch Semantics Guide

Examples:

  • PR Title: fix: patch MongoDB document update bug
  • Branch Name: feat/#1-login-flow (You may skip mentioning the issue number in the branch name if the change is small and the PR description clearly explains it.)

Additional checklist:

…eKeyPath

These fields serialize as empty strings in API responses when unset,
causing test failures for the k8s-proxy config endpoint.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Mar 26, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

This PR adds omitempty tags to two struct fields to prevent empty values from being serialized. The types remain unchanged (value types, not pointers), making this a safe, non-breaking change.

Changes Made:

  • config/config.go:93 - Added omitempty to TLSPrivateKeyPath tags (type: string)
  • pkg/models/instrument.go:19 - Added omitempty to FilterPolicy tags (type: FilterPolicy)

Previous Issues (All Resolved)

The previous review flagged concerns about pointer type changes (int*int, string*string, FilterPolicy*FilterPolicy). These changes have been reverted — all fields now remain as value types, eliminating the compilation and breaking change concerns.

Previous Issue Status
Obsolete changed from int to *int ✅ Reverted - not in current diff
TLSPrivateKeyPath changed from string to *string ✅ Reverted - field is string
FilterPolicy changed from FilterPolicy to *FilterPolicy ✅ Reverted - field is FilterPolicy
Type mismatches in record.go, cmd.go, util.go ✅ No longer applicable
Files Reviewed (2 files)
  • config/config.go - Tag-only change, no issues
  • pkg/models/instrument.go - Tag-only change, no issues

Reviewed by claude-4.5-opus-20251124 · 113,864 tokens

@github-actions
Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 2.99ms 6.66ms 763.01ms 98.86 0.00% ❌ FAIL
2 2.63ms 3.34ms 4.98ms 100.00 0.00% ✅ PASS
3 2.56ms 3.2ms 4.57ms 100.00 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

Result: PASSED - Only 1 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

Success int `json:"success" yaml:"success"`
Failure int `json:"failure" yaml:"failure"`
Obsolete int `json:"obsolete,omitempty" yaml:"obsolete,omitempty"`
Obsolete *int `json:"obsolete,omitempty" yaml:"obsolete,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CRITICAL: Changing Obsolete from int to *int causes compilation errors in 6+ locations that haven't been updated.

Affected locations:

  • pkg/service/report/report.go:174 - obsolete += rep.Obsolete - cannot add *int to int
  • pkg/service/report/report.go:205 - obsolete: rep.Obsolete - assigning *int to int field
  • pkg/service/replay/replay.go:1700 - obsolete: testReport.Obsolete - assigning *int to int field
  • pkg/service/replay/replay.go:1712 - r.totalTestObsolete += testReport.Obsolete - cannot add *int to int
  • pkg/service/replay/replay.go:1735 - testReport.Obsolete > 0 - cannot compare *int to int
  • pkg/service/replay/replay.go:1759 - testReport.Obsolete > 0 - cannot compare *int to int

Fix: Either revert to int type, or update all usages to dereference with nil checks, e.g.:

if testReport.Obsolete != nil && *testReport.Obsolete > 0 { ... }

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

This PR aims to prevent unset config/model fields from serializing as empty strings in API responses (notably impacting the k8s-proxy config endpoint), by adjusting struct field tags/optionality.

Changes:

  • Updated models.Filter.FilterPolicy to be optional and tagged with omitempty for JSON/YAML/BSON.
  • Updated config.Record.TLSPrivateKeyPath to be optional and tagged with omitempty for JSON/YAML/BSON.
  • Changed models.TestReport.Obsolete from int to *int.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pkg/models/testrun.go Changes TestReport.Obsolete to a pointer type, affecting how/when it serializes.
pkg/models/instrument.go Makes FilterPolicy optional with omitempty tags (currently via pointer type).
config/config.go Makes TLSPrivateKeyPath optional with omitempty tags (currently via pointer type).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 3.57ms 7.12ms 634.5ms 98.85 0.00% ❌ FAIL
2 2.87ms 3.79ms 5.41ms 100.02 0.00% ✅ PASS
3 2.69ms 3.53ms 5.99ms 100.02 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

Result: PASSED - Only 1 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

@github-actions
Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 3.74ms 7.1ms 708.57ms 98.79 0.00% ❌ FAIL
2 2.95ms 3.85ms 5.58ms 100.02 0.00% ✅ PASS
3 2.85ms 3.77ms 5.85ms 100.00 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

Result: PASSED - Only 1 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

@github-actions
Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 3.03ms 6.23ms 543.36ms 98.95 0.00% ❌ FAIL
2 2.59ms 3.31ms 5.12ms 100.02 0.00% ✅ PASS
3 2.51ms 3.18ms 4.48ms 100.00 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

Result: PASSED - Only 1 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

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.

2 participants