GetVirtualMachinesMetricID method throwing panic error when accessing VMs from reponse
- Lenguaje dominante
- Go
- Estrellas
- 39
- Forks
- 47
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
**Problem**: VirtualMachineService.GetVirtualMachinesMetricID method throws panic when it is trying to access the VMs response from server in below line of code. This happens when the count in the response is 1 but the actual VirtualMachinesMetrics array in the reponse is nil or empty. This is causing panic in the caller [CAPC](https://github.com/kubernetes-sigs/cluster-api-provider-cloudstack/blob/7b87895be9aa7d9dca1e2f70892feafd33ca4e59/pkg/cloud/instance.go#L61)
panic error is happening at: https://github.com/apache/cloudstack-go/blob/main/cloudstack/VirtualMachineService.go#L5543
**error**: `panic: runtime error: index out of range [0] with length 0`
version of cloudstack-go used: `2.16.1`
Please help investigate this error and let us know if this response is not expected
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Inspecciona cloudstack/VirtualMachineService.go en la línea 5543 y el invocador en pkg/cloud/instance.go en la línea 61 de CAPC. Reproduce la respuesta en la que count es 1, pero VirtualMachinesMetrics es nil o está vacío, y establece después el comportamiento esperado para que el método ya no entre en pánico y el comportamiento de la respuesta quede documentado o cubierto por una prueba de regresión.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- go
- Área
- api
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100