这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Bug: panic in timeseries if series is empty #2467

@svagner

Description

@svagner

Expected behaviour

if we have the expression:

timedelta(graphite("blabla.data", "1m", "", "foo.bar"))

And response from graphite is:

[{"target":"blabla.data","datapoints":[[null,1584627001],[null,1584627002],[null,1584627003],[null,1584627004],[null,1584627005],[null,1584627006],[null,1584627007],[null,1584627008],[null,1584627009],[null,1584627010]]}]

timedelta shouldn't do anything

Current behaviour

error: expr.go:143: Error: runtime error: index out of range [0] with length 0. Origin: Schedule: Alert Name: test_alert. Expression: 10 < sum(graphite("aliasByNode(asPercent(blabla,sum,sumSeries(blabla.sum)),1,2)", "2m", "", "tag1.tag2") < 99.99
 * timedelta(graphite("aliasByNode(asPercent(blabla.sum,sumSeries(blabla.sum)),1,2)", "2m", "", "tag1.tag2"))) / 10, Stack: goroutine 111217 [running]:
runtime/debug.Stack(0x1637320, 0x172b540, 0xc1e99c79a0)
        /usr/lib64/go/src/runtime/debug/stack.go:24 +0x9d
bosun.org/cmd/bosun/expr.errRecover(0xc1e5b0be58, 0xc0339c63c0)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:143 +0x229
panic(0x172b540, 0xc1e99c79a0)
        /usr/lib64/go/src/runtime/panic.go:973 +0x396
bosun.org/cmd/bosun/expr.TimeDelta(0xc0339c63c0, 0xc1ee39e2d0, 0x0, 0x0, 0x0)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/funcs.go:1138 +0x331
reflect.Value.call(0x15f7e60, 0x1b142f8, 0x13, 0x1882508, 0x4, 0xc1ee39e450, 0x2, 0x2, 0x2, 0x18, ...)
        /usr/lib64/go/src/reflect/value.go:460 +0x8ab
reflect.Value.Call(0x15f7e60, 0x1b142f8, 0x13, 0xc1ee39e450, 0x2, 0x2, 0x1, 0x1, 0x8)
        /usr/lib64/go/src/reflect/value.go:321 +0xb4
bosun.org/cmd/bosun/expr.(*State).walkFunc.func1(0x1d0eaa0, 0xc1cc696120)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:792 +0xeb4
github.com/MiniProfiler/go/miniprofiler.(*Profile).Step(0xc1cc696120, 0xc1edb7d1c0, 0xf, 0xc1ee39bd60)
        /builddir/build/BUILD/bosun-0.8.0/GO/pkg/mod/github.com/!mini!profiler/go@v0.0.0-20160719195834-3296d396d472/miniprofiler/types.go:195 +0x76
bosun.org/cmd/bosun/expr.(*State).walkFunc(0xc0339c63c0, 0xc0264de1e0, 0xc1ee39e150)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:744 +0xff
bosun.org/cmd/bosun/expr.(*State).walk(0xc0339c63c0, 0x1d14500, 0xc0264de1e0, 0xc1ee39e150)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:496 +0x10d
bosun.org/cmd/bosun/expr.(*State).walkBinary(0xc0339c63c0, 0xc0262e04e0, 0xc1c344d160)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:519 +0x8f
bosun.org/cmd/bosun/expr.(*State).walkFunc.func1(0x1d0eaa0, 0xc1cc696120)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:758 +0x12c4
github.com/MiniProfiler/go/miniprofiler.(*Profile).Step(0xc1cc696120, 0xc1c34458f0, 0x9, 0xc25d3ff1a0)
        /builddir/build/BUILD/bosun-0.8.0/GO/pkg/mod/github.com/!mini!profiler/go@v0.0.0-20160719195834-3296d396d472/miniprofiler/types.go:195 +0x76
bosun.org/cmd/bosun/expr.(*State).walkFunc(0xc0339c63c0, 0xc0264de140, 0x203070)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:744 +0xff
bosun.org/cmd/bosun/expr.(*State).walk(0xc0339c63c0, 0x1d14500, 0xc0264de140, 0xc1c3445830)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:496 +0x10d
bosun.org/cmd/bosun/expr.(*State).walkBinary(0xc0339c63c0, 0xc0262e0540, 0x1e)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:518 +0x5a
bosun.org/cmd/bosun/expr.(*State).walk(0xc0339c63c0, 0x1d14440, 0xc0262e0540, 0xc1c3460de0)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:492 +0x1a3
bosun.org/cmd/bosun/expr.(*State).walkBinary(0xc0339c63c0, 0xc0262e05a0, 0x40e036)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:519 +0x8f
bosun.org/cmd/bosun/expr.(*State).walk(0xc0339c63c0, 0x1d14440, 0xc0262e05a0, 0xc0000b95e8)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:492 +0x1a3
bosun.org/cmd/bosun/expr.(*Expr).ExecuteState.func1(0x1d0eaa0, 0xc1cc696120)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:130 +0x4c
github.com/MiniProfiler/go/miniprofiler.(*Profile).Step(0xc1cc696120, 0x188caa9, 0xc, 0xc25d3ff180)
        /builddir/build/BUILD/bosun-0.8.0/GO/pkg/mod/github.com/!mini!profiler/go@v0.0.0-20160719195834-3296d396d472/miniprofiler/types.go:195 +0x76
bosun.org/cmd/bosun/expr.(*Expr).ExecuteState(0xc0255ff180, 0xc0339c63c0, 0x400, 0x0, 0x0, 0x0, 0x0, 0x0)
github.com/MiniProfiler/go/miniprofiler.(*Profile).Step(0xc1cc696120, 0x188caa9, 0xc, 0xc25d3ff180)
        /builddir/build/BUILD/bosun-0.8.0/GO/pkg/mod/github.com/!mini!profiler/go@v0.0.0-20160719195834-3296d396d472/miniprofiler/types.go:195 +0x76
bosun.org/cmd/bosun/expr.(*Expr).ExecuteState(0xc0255ff180, 0xc0339c63c0, 0x400, 0x0, 0x0, 0x0, 0x0, 0x0)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:129 +0x148
bosun.org/cmd/bosun/expr.(*Expr).Execute(0xc0255ff180, 0xc029c0d6c0, 0xc1c3405bc0, 0x0, 0x0, 0x3510de78, 0xed605707b, 0x0, 0x0, 0xc029f3f900, ...)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/expr/expr.go:119 +0xff
bosun.org/cmd/bosun/sched.(*Schedule).executeExpr(0xc028769680, 0x0, 0x0, 0xc1509aff40, 0xc0263ab6c0, 0xc0255ff180, 0x0, 0x43f426, 0x1b19da0)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/sched/check.go:743 +0x221
bosun.org/cmd/bosun/sched.(*Schedule).CheckExpr.func2(0xc028769680, 0x0, 0x0, 0xc1509aff40, 0xc0263ab6c0, 0xc0255ff180, 0xc1c344bf80)
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/sched/check.go:766 +0x6d
created by bosun.org/cmd/bosun/sched.(*Schedule).CheckExpr
        /builddir/build/BUILD/bosun-0.8.0/GO/src/bosun.org/cmd/bosun/sched/check.go:765 +0x147
panic: runtime error: index out of range [0] with length 0 [recovered]
        panic: runtime error: index out of range [0] with length 0

Context

bosun version from the current master branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions