Juniper / terraform-provider-apstra

Apstra Terraform Provider
Apache License 2.0
16 stars 2 forks source link

Fix nil pointer deref when `GetNodeRenderedConfigDiff()` returns 404 #968

Closed chrismarget-j closed 3 weeks ago

chrismarget-j commented 3 weeks ago

Calls to GetNodeRenderedConfigDiff() may return error due to 404 from the API.

964 introduced a change which made these errors not fatal for the data source. We want to just return a null incremental config in those cases.

Unfortunately, the incremental config is returned via a *apstra.RenderDiff (a pointer), which is nil on 404. Because 964 causes us to not return, we go on to dereference a value within that nil struct pointer, leading to a crash.

This PR tightens up the preceding code a bit (disambiguates some stuff no longer needed since #964) and checks the pointer before attempting to dereference the config diff.

Closes #967