Closed gfysaris closed 2 months ago
Appreciate the detailed error report, thank you! I believe this was already fixed with #135, but it wasn't yet included in a release. I've tagged and released v1.1.2
which should address this, would you mind giving that a test to make sure it resolves your issue?
Thanks for the update Alex! Indeed i've just tested with 1.1.3 and it worked. Thank you
Describe the bug
Terraform and Provider Version
Terraform File and Steps to Reproduce
data.external.megaport_partners.tf
get_all_megaport_partners.sh
data.megaport_partner.tf
Additional context Based on troubleshoot analysis from Gitlab AI
Root cause of failure The root cause of this job failure appears to be a crash in the Terraform provider plugin for Megaport (terraform-provider-megaport_v1.1.1). Specifically, the error occurs during the execution of the ReadDataSource function in the partnerPortDataSource struct.
The crash is caused by a panic due to an "index out of range" error, which suggests that the code is trying to access an element in a slice or array that doesn't exist. The exact line causing the issue is in the file partner_port_data_source.go at line 281.
The error message indicates:
This means that the code is trying to access the first element (index 0) of a slice or array that is empty (length 0).
The crash in the provider plugin causes Terraform to fail, as it cannot complete the operation it was trying to perform (likely reading data from a data source).
Example Fix To fix this issue, the Megaport Terraform provider code needs to be updated to handle the case where the slice or array might be empty. Here's an example of how the fix might look:
This example adds a check to ensure that the slice has at least one element before trying to access it. If the slice is empty, it adds an error diagnostic and returns from the function.
To implement this fix, the Megaport Terraform provider maintainers would need to:
Identify the exact slice or array causing the issue. Add appropriate checks to handle cases where the data might be empty. Implement error handling or default values as appropriate for their use case. Test the changes thoroughly to ensure they resolve the issue without introducing new problems. Release a new version of the provider with the fix. Users of the Terraform Megaport provider would then need to update to the new version once it's released to resolve this issue in their CI/CD pipelines.