From 2ef3682560a31bd03f0ba70eb6ec509512ad0de8 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Mon, 20 Mar 2017 11:37:06 +0100 Subject: [PATCH] Hotfix erroneous "label index missing" error --- index.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.go b/index.go index f95708576..d0e557dd6 100644 --- a/index.go +++ b/index.go @@ -567,7 +567,10 @@ func (r *indexReader) LabelValues(names ...string) (StringTuples, error) { key := strings.Join(names, string(sep)) off, ok := r.labels[key] if !ok { - return nil, fmt.Errorf("label index doesn't exist") + // XXX(fabxc): hot fix. Should return a partial data error and handle cases + // where the entire block has no data gracefully. + return emptyStringTuples{}, nil + //return nil, fmt.Errorf("label index doesn't exist") } flag, b, err := r.section(off) @@ -590,6 +593,11 @@ func (r *indexReader) LabelValues(names ...string) (StringTuples, error) { return st, nil } +type emptyStringTuples struct{} + +func (emptyStringTuples) At(i int) ([]string, error) { return nil, nil } +func (emptyStringTuples) Len() int { return 0 } + func (r *indexReader) LabelIndices() ([][]string, error) { res := [][]string{}