abcxyz / abcxyz/abc-updater

Bad ABC_METRICS_URL causes SEGFAULT

Abierto
#105 0 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
Go
Estrellas
1
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### TL;DR

[Found in `abc`]

If you do
```shell
export ABC_METRICS_URL=""
abc # anyh command
```

You get

```shell
$ abc
metric client creation failed: failed to parse server URL: parse "": empty url
Usage: abc COMMAND

describe show the description and inputs of a given template
golden-test subcommands for validating template rendering with golden tests
render instantiate a template to setup a new app or add config files
templates subcommands for rendering templates and related things
upgrade apply a new template version to an already-rendered template output directory
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0xa6b3ac]

goroutine 38 [running]:
github.com/abcxyz/abc-updater/pkg/metrics.(*Client).WriteMetric(0x0?, {0xfacac0?, 0xc0002a4140?}, {0xe7783e?, 0x0?}, 0x0?)
/usr/local/google/home/pdewilde/go/pkg/mod/github.com/abcxyz/abc-updater@v0.3.0/pkg/metrics/metrics.go:212 +0x4c
github.com/abcxyz/abc/internal/metricswrap.WriteMetric.func1()
/usr/local/google/home/pdewilde/go/pkg/mod/github.com/abcxyz/abc@v0.10.0-alpha/internal/metricswrap/metrics.go:37 +0x71
created by github.com/abcxyz/abc/internal/metricswrap.WriteMetric in goroutine 1
/usr/local/google/home/pdewilde/go/pkg/mod/github.com/abcxyz/abc@v0.10.0-alpha/internal/metricswrap/metrics.go:34 +0xfe
```

### Expected behavior

Fail silently

### Observed behavior

Segfault

### Environment Details

```markdown
Linux, abc v0.10.0-alpha
```

### Additional information

_No response_

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

The segfault occurs in github.com/abcxyz/abc-updater/pkg/metrics.(*Client).WriteMetric at line 212 of metrics.go. Start by examining the metrics client initialization and the WriteMetric method to see where a nil pointer is dereferenced when ABC_METRICS_URL is empty. The fix likely involves checking for a nil client before writing metrics. Run the CLI with the empty environment variable to reproduce the crash.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Área
cli
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.