mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 04:55:55 +08:00
fix: avoid pipeline builder panic when first op is disabled (#3500)
* fix: avoid pipeline builder panic if first op is disabled * chore: use pipeline builder test to trigger getOperator panic --------- Co-authored-by: Nityananda Gohain <nityanandagohain@gmail.com>
This commit is contained in:
parent
921fca5e67
commit
f450d71a25
@ -58,7 +58,7 @@ func getOperators(ops []model.PipelineOperator) []model.PipelineOperator {
|
|||||||
filteredOp := []model.PipelineOperator{}
|
filteredOp := []model.PipelineOperator{}
|
||||||
for i, operator := range ops {
|
for i, operator := range ops {
|
||||||
if operator.Enabled {
|
if operator.Enabled {
|
||||||
if i > 0 {
|
if len(filteredOp) > 0 {
|
||||||
filteredOp[len(filteredOp)-1].Output = operator.ID
|
filteredOp[len(filteredOp)-1].Output = operator.ID
|
||||||
}
|
}
|
||||||
filteredOp = append(filteredOp, operator)
|
filteredOp = append(filteredOp, operator)
|
||||||
|
@ -163,6 +163,29 @@ var prepareProcessorTestData = []struct {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "first op disabled",
|
||||||
|
Operators: []model.PipelineOperator{
|
||||||
|
{
|
||||||
|
ID: "move_filename",
|
||||||
|
Output: "move_function",
|
||||||
|
Enabled: false,
|
||||||
|
Name: "move_filename",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: "move_function",
|
||||||
|
Enabled: true,
|
||||||
|
Name: "move_function",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Output: []model.PipelineOperator{
|
||||||
|
{
|
||||||
|
ID: "move_function",
|
||||||
|
Enabled: true,
|
||||||
|
Name: "move_function",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPreparePipelineProcessor(t *testing.T) {
|
func TestPreparePipelineProcessor(t *testing.T) {
|
||||||
|
@ -231,8 +231,8 @@ func (tb *LogPipelinesTestBed) PostPipelinesToQSExpectingStatusCode(
|
|||||||
|
|
||||||
if response.StatusCode != expectedStatusCode {
|
if response.StatusCode != expectedStatusCode {
|
||||||
tb.t.Fatalf(
|
tb.t.Fatalf(
|
||||||
"Received response status %d after posting log pipelines. Expected: %d",
|
"Received response status %d after posting log pipelines. Expected: %d\nResponse body:%s\n",
|
||||||
response.StatusCode, expectedStatusCode,
|
response.StatusCode, expectedStatusCode, string(responseBody),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user