SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: added 404 for error in getRule api (#1309)
Ankit Nayanafbcde5edc9f
diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.goindex 1258060c41..f405c69f6d 100644--- a/pkg/query-service/app/clickhouseReader/reader.go+++ b/pkg/query-service/app/clickhouseReader/reader.go@@ -592,21 +592,45 @@ func (r *ClickHouseReader) GetRulesFromDB() (*[]model.RuleResponseItem, *model.Afunc (r *ClickHouseReader) GetRule(id string) (*model.RuleResponseItem, *model.ApiError) {- idInt, _ := strconv.Atoi(id)+ idInt, err := strconv.Atoi(id)+ if err != nil {+ zap.S().Debug("Error in parsing param: ", err)+ return nil, &model.ApiError{Typ: model.ErrorBadData, Err: err}+ }rule := &model.RuleResponseItem{}- query := fmt.Sprintf("SELECT id, updated_at, data FROM rules WHERE id=%d", idInt)-- err := r.localDB.Get(rule, query)-- zap.S().Info(query)+ query := "SELECT id, updated_at, data FROM rules WHERE id=?"+ rows, err := r.localDB.Query(query, idInt)if err != nil {zap.S().Debug("Error in processing sql query: ", err)return nil, &model.ApiError{Typ: model.ErrorInternal, Err: err}}+ count := 0+ // iterate over each row+ for rows.Next() {+ err = rows.Scan(&rule.Id, &rule.UpdatedAt, &rule.Data)+ if err != nil {+ zap.S().Debug(err)+ return nil, &model.ApiError{Typ: model.ErrorInternal, Err: err}+ }+ count += 1++ }++ if count == 0 {+ err = fmt.Errorf("no rule with id %d found", idInt)+ zap.S().Debug(err)+ return nil, &model.ApiError{Typ: model.ErrorNotFound, Err: err}+ }+ if count > 1 {+ err = fmt.Errorf("multiple rules with id %d found", idInt)+ zap.S().Debug(err)+ return nil, &model.ApiError{Typ: model.ErrorConflict, Err: err}+ }+return rule, nil}