Repository navigation
Conversation
Endpoint attributes are free-form (`map[string]apiext.JSON`) in v1alpha2 but string-based (`map[string]string`) in v1alpha1. Conversion from v1alpha2 is implemented as a JSON round-trip, so an endpoint holding a non-string attribute such as `discoverable: true` failed to convert with: cannot unmarshal bool into Go struct field Endpoint.container.endpoints.attributes of type string Rewrite the endpoint attributes of the marshalled component into their string representation before decoding into v1alpha1. Values keep their verbatim JSON text rather than going through `GetString`, so no precision is lost: `1048576` becomes "1048576" and not "1.048576e+06". The three conversion paths that decode a component from v1alpha2 are covered: plain components, plugin component overrides and parent component overrides, across the container, kubernetes and openshift component types. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Anatolii Bazko <abazko@redhat.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe v1alpha2-to-v1alpha1 component conversion paths now stringify endpoint attribute values before decoding the destination. Tests cover container components, plugin component overrides, parent component overrides, and several JSON value types. ChangesEndpoint Attribute Conversion
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No identified conversion defect remains; the change is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change is confined to API conversion and preserves endpoint identity and security fields. No introduced authorization bypass was established. Attribute types are not restored after conversion through the older API version, and downstream uses of structured attributes remain unverified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1791 +/- ##
==========================================
- Coverage 35.75% 30.36% -5.40%
==========================================
Files 52 68 +16
Lines 6696 8162 +1466
==========================================
+ Hits 2394 2478 +84
- Misses 4158 5525 +1367
- Partials 144 159 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I tested with the abovementioned steps and can confirm it works as expected ✔️ |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dkwon17, rohanKanojia, tolusha The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Description of Changes
Fixes the v1alpha2 -> v1alpha1 conversion of endpoints whose attributes hold a non-string value.
Endpoint attributes are free-form (
map[string]apiext.JSON) in v1alpha2 but string-based (map[string]string) in v1alpha1. Conversion from v1alpha2 is implemented as a JSON round-trip, so an endpoint declaring something like:fails to convert with:
This PR rewrites the endpoint attributes of the marshalled component into their string representation before decoding into v1alpha1.
ses these strings back when converting to v1alpha2 again, so
discoverable: truecomes out of a v1alpha2 -> v1alpha1 -> v1alpha2 round-trip as the string"true". Scalars stay usable, becauseGetBooleanandGetNumberfall back tostrconvwhen the attribute holds a string, but an object or an array comes back as a string and no longer decodes withGetInto.Parsing the strings back is not an option: a string attribute the user actually authored as
"true"cannot be told apart from a stringified boolean. This is inherent to the v1alpha1 schema, which has no way to represent a non-string attribute.The conversion is one way. Nothing parses these strings back when converting to v1alpha2 again, so
discoverable: truecomes out of a v1alpha2 -> v1alpha1 -> v1alpha2 round-trip as the string"true". Scalars stay usable, becauseGetBooleanandGetNumberfall back tostrconvwhen the attribute holds a string, but an object or an array comes back as a string and no longer decodes withGetInto.Parsing the strings back is not an option: a string attribute the user actually authored as
"true"cannot be told apart from a stringified boolean. This is inherent to the v1alpha1 schema, which has no way to represent a non-string attribute.Related Issue(s)
https://redhat.atlassian.net/browse/CRW-12643
Acceptance Criteria
Testing and documentation do not need to be complete in order for this PR to be approved. However, tracking issues must be opened for missing testing/documentation.
New testing and documentation issues can be opened under
devfile/api/issues.You can check the respective criteria below if either of the following is true:
If criteria is left unchecked please provide an explanation why.
Tests Performed
Explain what tests you personally ran to ensure the changes are functioning as expected.
How To Test
git clone git@github.com:devfile/devworkspace-operator.git cd devworkspace-operator make installdiscoverable: trueoc logs -n devworkspace-controller deployment/devworkspace-controller-manager -f ... "json: cannot unmarshal bool into Go struct field Endpoint.container.endpoints.attributes of type string" ...devfile/apidependencyquay.io/abazko/operator:dw-test) and update DWO deploymentNotes To Reviewer
Any notes you would like to include for the reviewer.