Prevent API undefined property: stdClass:$server error when firewall has attached tags #83
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.
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!