Skip to content

fix: preserve explode presence in parameter hashes - #704

Open
pcbeingused333 wants to merge 2 commits into
pb33f:mainfrom
pcbeingused333:fix/c2526-parameter-explode
Open

pcbeingused333 wants to merge 2 commits into
pb33f:mainfrom
pcbeingused333:fix/c2526-parameter-explode

Conversation

@pcbeingused333

Copy link
Copy Markdown

Parameter hashes currently treat an omitted explode and explicit explode: false as equal. For a query array parameter using the default form style, adding explode: false changes serialization from a=1&a=2 to a=1,2, but the equality shortcut prevents the diff engine from reporting it.

Hash the explode value only when its YAML value node is present. The existing diff logic can then report the property addition or removal, preserving the repository's current non-breaking classification.

For example, compare name: a, in: query, schema: {type: array} against the same parameter with explode: false added. The expected result is one explode property addition.

Testing and validation

Added focused hash regressions for absent, false, and true values, plus diff regressions for adding and removing explicit false.

  • go test ./datamodel/low/v3/ ./what-changed/... -run 'Explode|Parameter' -count=1 passes; with the parameter.go change reverted, TestParameter_Hash_ExplodePresence and TestCompareParameters_V3_ExplodePresence fail (CompareParameters returns nil).
  • go test ./... -count=1 passes.

This change was prepared with AI assistance (Codex).

@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (867b126) to head (08cbbd2).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #704   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          315       315           
  Lines        39762     39759    -3     
=========================================
- Hits         39762     39759    -3     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread datamodel/low/v3/parameter.go Outdated
low.HashString(h, "style", p.Style.Value)
}
low.HashBool(h, p.Explode.Value)
if p.Explode.ValueNode != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[P2] Use the same presence check as NewParameter. I set Explode on a built low-level parameter to low.NodeReference[bool]{KeyNode: key, Value: true}. NewParameter(p).Render() wrote explode: true, but low.AreEqual returned true against the parameter with explode omitted. The base distinguished these values. NodeReference.IsEmpty() checks both node pointers, and the high model uses that method. Please use !p.Explode.IsEmpty() here and add a key-only regression alongside the parsed cases.

Use the same IsEmpty check as NewParameter so a key-only Explode
reference is not treated as omitted.
@pcbeingused333

Copy link
Copy Markdown
Author

The presence check in Parameter.Hash now uses !p.Explode.IsEmpty(), the same check as NewParameter. A low-level parameter with only Explode.KeyNode set and value true no longer compares equal to one that omits explode, and it hashes the same as a parsed explode: true. TestParameter_Hash_ExplodePresence covers that key-only case next to the parsed absent, false, and true cases.

This comment was drafted with AI assistance.

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