hetznercloud / hcloud-go

A Go library for the Hetzner Cloud API
https://pkg.go.dev/github.com/hetznercloud/hcloud-go/v2/hcloud
MIT License
390 stars 45 forks source link

fix(metadata): trim responses before parsing #540

Closed apricote closed 2 weeks ago

apricote commented 4 weeks ago

TL;DR

Responses from metadata service are not trimmed before parsing. They rely on underspecified behaviour of the metadata service api.

Expected behavior

Before parsing the response, we should at least trim any excessive whitespace

Observed behavior

If the response contains any whitespace (like a newline at the end of it), the parsing of some of the fields fails.

This applies to InstanceID(), PublicIPv4().

In addition, the return values of all other functions would also include the additional whitespace, leading to unexpected results downstream.

Minimal working example

No response

Log output

No response

Additional information

No response