Bad ABC_METRICS_URL causes SEGFAULT
- Langage dominant
- Go
- Étoiles
- 1
- Forks
- 0
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
### 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_
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Domaine
- cli
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 45/100