Skip to content

Conversation

Tarun-kishore
Copy link
Contributor

Description

Fixed incorrect serialization of the creation field in ExplainSMPolicy.toXContent(). The method was using .field() instead of .optionalField() for the nullable creation field, which is inconsistent with how the deletion field is handled and with the reference implementation in SMMetadata.toXContent().

Changed line 39 in ExplainSMPolicy.kt:

  • Before: .field(SMMetadata.CREATION_FIELD, it.creation)
  • After: .optionalField(SMMetadata.CREATION_FIELD, it.creation)

This ensures proper handling of null creation workflow metadata in Explain API responses and aligns with the serialization behavior in SMMetadata.

Related Issues

Resolves #1506

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

metadata?.let {
builder
.field(SMMetadata.CREATION_FIELD, it.creation)
.optionalField(SMMetadata.CREATION_FIELD, it.creation)
Copy link
Collaborator

Choose a reason for hiding this comment

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

will this have bwc issue when doing rolling upgrade? guess we need to add version check here

Copy link
Contributor Author

@Tarun-kishore Tarun-kishore Oct 13, 2025

Choose a reason for hiding this comment

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

Yes, Good catch. Added a version check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Hailong-am I added a version check for greater than 3.3 (which is current version). The coverage is failing though, version 3.4 needs to be available for testing it. Rest all CI workflows are passing.

Signed-off-by: Tarun-kishore <[email protected]>
@Tarun-kishore Tarun-kishore force-pushed the bug-fix/explain-serialization branch from b07015e to 5079606 Compare October 13, 2025 10:34
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.49%. Comparing base (3cf62f0) to head (5079606).

Files with missing lines Patch % Lines
...gement/snapshotmanagement/model/ExplainSMPolicy.kt 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1507      +/-   ##
==========================================
+ Coverage   76.47%   76.49%   +0.01%     
==========================================
  Files         375      375              
  Lines       18835    18838       +3     
  Branches     2401     2402       +1     
==========================================
+ Hits        14405    14410       +5     
- Misses       3182     3184       +2     
+ Partials     1248     1244       -4     

☔ View full report in Codecov by Sentry.
📢 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.

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] ExplainSMPolicy incorrectly uses .field() for nullable creation field

2 participants