CB-599: a capacity refusal must tell the caller why #93
Reference in New Issue
Block a user
Delete Branch "worker/cb599-740fe4-16"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PlacementException extends IllegalStateException, which neither BridgedApp.spawnMember nor BridgeMcp.spawn caught, so a maxLoad/quarantine/all-exhausted refusal fell through to a blank text/plain 500 on REST and lost its message on MCP.
Fix: catch PlacementException on both surfaces (before the unrelated unknown_profile IllegalArgumentException mapping) and return its message structured:
No throw-site messages were reworded. All PlacementException throw sites (FixedPlacementPolicy, WeightedRoundRobinPolicy, PlacementPolicyUtil, CompositePeerLauncher.enforceMaxLoad/enforceNotQuarantined) already produce clear messages; the gap was purely in delivery to the caller.
Tests: BridgedAppTest#spawnAtMaxLoadIs503WithTheCapacityReasonNotABare500 and BridgeMcpTest#spawnAtMaxLoadSurfacesTheCapacityReason both wire a CompositePeerLauncher with a maxLoad:0 profile and assert the caller can read the reason on each surface.
mvn -f bridged/pom.xml clean install: Tests run: 824, Failures: 0, Errors: 0, Skipped: 0 -- BUILD SUCCESS (run unpiped).
PlacementException extends IllegalStateException, which neither BridgedApp nor BridgeMcp's spawn catch blocks handled, so a maxLoad/quarantine/ all-exhausted refusal fell through to a blank 500 on REST and lost its message on MCP. Catch it on both surfaces, ahead of the unrelated IllegalArgumentException(unknown_profile) mapping, and return its message structured: REST as {"error":"no_capacity","detail":...} with status 503, MCP as an isError result prefixed "no capacity: ...".