hetzner-cloud-php-sdk icon indicating copy to clipboard operation
hetzner-cloud-php-sdk copied to clipboard

Prevent API undefined property: stdClass:$server error when firewall has attached tags

Open geisi opened this issue 4 years ago • 0 comments

Hello this is my first PR in this project:

Before this PR following error occurred when you query a firewall with an attached label:

Undefined property: stdClass::$server thrown in hetzner-cloud-php-sdk/src/Models/Firewalls/Firewall.php:125

I reproduced this error by extending the firewall.json and firewalls.json fixtures with tag objects.

This error happens because the firewall model assumes that only server resources can be attached to a firewall.

This PR checks every firewall applied service and only adds it to the appliedTo array when it is a server object. This is only a workaround around this problem. In the future these tags(and their corresponding servers) should also be applied to the appliedTo array but this needs some bigger refactoring in the firewall model code. So this is only a quick fix.

Thank you for your hard work!

geisi avatar Oct 13 '21 13:10 geisi