Skip to content

Fix route options serialization to preserve explicitly removed values#5010

Open
hoffmaen wants to merge 1 commit intocloudfoundry:mainfrom
sap-contributions:fix-route-options-removal
Open

Fix route options serialization to preserve explicitly removed values#5010
hoffmaen wants to merge 1 commit intocloudfoundry:mainfrom
sap-contributions:fix-route-options-removal

Conversation

@hoffmaen
Copy link
Copy Markdown
Contributor

@hoffmaen hoffmaen commented Apr 9, 2026

Summary

When a route option (e.g., loadbalancing) is explicitly removed via the API, the value is set to nil internally. The options= setter previously called .compact on the options hash, which removed nil keys entirely from the serialized JSON. This made the resulting "options":{} indistinguishable from a route that never had options set, preventing downstream consumers (e.g., gorouter) from detecting the explicit removal and reverting to the platform default.

Fixes cloudfoundry/routing-release#551

Changes

  • Replace .compact with .transform_values { |v| v.nil? ? '' : v } in Route#options_with_serialization=, so that explicitly removed options are serialized as empty strings (e.g., "options":{"loadbalancing":""}) instead of being dropped
  • Update assertions in route_update_spec.rb and manifest_route_update_spec.rb to expect { 'loadbalancing' => '' } instead of {}
  • Add a new model-level test in route_spec.rb that explicitly verifies nil option values are serialized as empty strings

Context

This is the Cloud Controller counterpart to a gorouter issue (cloudfoundry/routing-release#551) that adds support for reverting a per-route load balancing algorithm to the platform default. Without this CC change, the removal signal is lost before it reaches gorouter via NATS.

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

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.

Per-route load balancing algorithm is not reset to platform default when removed from a route

1 participant