fix(operations): the inventory read a location Hetzner no longer sends - #193
Merged
Merged
Conversation
`toInventoryServer` resolved the place name as
`datacenter.location.name ?? datacenter.name ?? location`, treating the last
one as a bare string. Hetzner has retired `datacenter` - it sends an explicit
`null` - and nests the place under `location` as an object, so on a live
listing all three reads miss and every box reports no location at all.
`buddy cloud:sites` printed the column empty for the whole fleet.
ts-cloud already knew this. `resize.ts` reads `location?.name` first and
`role-swap.ts` carries a comment and a regression suite about the same
retirement; this reader was written against the recorded fixtures and picked
up the legacy order. It now reads the current shape first and accepts either
`{ name }` or a bare string, so the older fixtures and a non-Hetzner driver
with a flatter listing both still resolve.
While here, `raw: any` becomes `ProviderServerPayload`, matching the sweep in
stacks c379cee. The null on `datacenter` is in the type because null is what
the API actually sends - stating it is what let the regression test drop its
cast.
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.
The bug
toInventoryServerresolved a box's place name as:Hetzner has retired
datacenter(it sends an explicitnull) and nests the place underlocationas an object. So on a live listing:datacenter.location.namemisses,datacenteris nulldatacenter.namemisses, same reasonlocationmisses, because it is{ name: 'fsn1' }andtext()only accepts a stringAll three miss and every box reports no location at all.
buddy cloud:sitesprints the column empty for the whole fleet.ts-cloud already knew
This is not new information to this package, which is what makes it worth fixing rather than shrugging at:
drivers/hetzner/resize.ts:116readsserver.location?.name ?? server.datacenter?.location.name- current shape first.drivers/hetzner/role-swap.tscarries a comment about the retirement and a regression suite for it, includingfalls back to the location now that datacenter is gonewith the note "The current API shape: datacenter null, location present."operations/inventory.tswas written against the recorded fixtures, which still carrydatacenter, so it picked up the legacy order and the string assumption. This is the third reader to need the same fallback.The fix
A
placeName()helper that accepts either{ name }or a bare string, read in the current-shape-first order the rest of the package uses. Older fixtures withdatacenterstill resolve, and a non-Hetzner driver answering a flat string still resolves.Also here
raw: anybecomesProviderServerPayload, matching theanysweep Chris ran over the copy that used to live in stacks (c379cee). Two notes on the shape:ipv4/ipv6/type/locationfields are declared alongside the nested ones, because this function's contract is that a simpler driver can satisfy it. The stacks copy did not read those, so its interface did not need them.datacenteris typed| nullbecause null is what the API actually sends. Stating that is what let the regression test drop the cast it needed at first - a cast there would have been the type disagreeing with reality.Verification
24 pass / 1 fail) and green on the new.operations: 126 pass / 0 fail.typecheckclean,lintclean (865 files),buildclean.Follow-up to #192.