fix: omitempty on Service.Name so provision references serialize href-only - #19
Open
adityakrishnan142 wants to merge 1 commit into
Open
fix: omitempty on Service.Name so provision references serialize href-only#19adityakrishnan142 wants to merge 1 commit into
adityakrishnan142 wants to merge 1 commit into
Conversation
Service.Name was tagged `json:"name"` (no omitempty) while every other
provisionable type (RuleSet, IPList, LabelGroup, VirtualService,
VirtualServer, EnforcementBoundary) uses `name,omitempty`.
ProvisionHref builds href-only references (&Service{Href: h}), so the unset
Name serialized as "name":"" in the change_subset. The PCE's
POST /sec_policy rejects that with 406 invalid_uri / not_acceptable, so
`workloader delete --provision` of services never commits — the deleted
services linger in a pending-delete draft and later 406 rule-import with
"Can not assign deleted service".
Adding omitempty makes a service provision reference serialize href-only
({"href":"..."}) like the other types, while a populated Name still
serializes for normal create/update. Adds regression tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Service.Nameis taggedjson:"name"(noomitempty), while every other provisionable type —RuleSet,IPList,LabelGroup,VirtualService,VirtualServer,EnforcementBoundary— usesjson:"name,omitempty".ProvisionHrefbuilds href-only references:Because
Namehas noomitempty, the unset field serializes into thechange_subsetas"name":"". The PCE'sPOST /sec_policyrejects that body:Real-world impact:
workloader delete --provisionof services never commits — the deleted services linger in a pending-delete draft, and a laterrule-importthen 406s withCan not assign deleted service, leaving rulesets empty. (Other types in the same batch provision fine, which is what pointed atServicespecifically.)Fix
Add
omitemptytoService.Name, matching the other provisionable structs. A service provision reference now serializes href-only ({"href":"..."}), while a populatedNamestill serializes for the normal create/update path.Tests
Adds
services_provision_test.go:TestServiceProvisionHrefOnly—&Service{Href: h}marshals to exactly{"href":"..."}with noname.TestServiceNameOmittedWhenEmpty— empty name omitted; non-empty name still serialized.Both pass (
go test), andgo build ./...is clean.