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: return 404 status code if rule not found (#8940)
aniketio-ctrl3cc5a24a4b5b
diff --git a/pkg/query-service/app/http_handler.go b/pkg/query-service/app/http_handler.goindex 7988283966..3d9d9f5cfe 100644--- a/pkg/query-service/app/http_handler.go+++ b/pkg/query-service/app/http_handler.go@@ -3,6 +3,7 @@ package appimport ("bytes""context"+ "database/sql""encoding/base64""encoding/json""errors"@@ -670,6 +671,10 @@ func (aH *APIHandler) getRule(w http.ResponseWriter, r *http.Request) {ruleResponse, err := aH.ruleManager.GetRule(r.Context(), id)if err != nil {+ if errors.Is(err, sql.ErrNoRows) {+ RespondError(w, &model.ApiError{Typ: model.ErrorNotFound, Err: fmt.Errorf("rule not found")}, nil)+ return+ }RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: err}, nil)return}@@ -1384,6 +1389,10 @@ func (aH *APIHandler) deleteRule(w http.ResponseWriter, r *http.Request) {err := aH.ruleManager.DeleteRule(r.Context(), id)if err != nil {+ if errors.Is(err, sql.ErrNoRows) {+ RespondError(w, &model.ApiError{Typ: model.ErrorNotFound, Err: fmt.Errorf("rule not found")}, nil)+ return+ }RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: err}, nil)return}@@ -1412,6 +1421,10 @@ func (aH *APIHandler) patchRule(w http.ResponseWriter, r *http.Request) {gettableRule, err := aH.ruleManager.PatchRule(r.Context(), string(body), id)if err != nil {+ if errors.Is(err, sql.ErrNoRows) {+ RespondError(w, &model.ApiError{Typ: model.ErrorNotFound, Err: fmt.Errorf("rule not found")}, nil)+ return+ }RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: err}, nil)return}@@ -1438,6 +1451,10 @@ func (aH *APIHandler) editRule(w http.ResponseWriter, r *http.Request) {err = aH.ruleManager.EditRule(r.Context(), string(body), id)if err != nil {+ if errors.Is(err, sql.ErrNoRows) {+ RespondError(w, &model.ApiError{Typ: model.ErrorNotFound, Err: fmt.Errorf("rule not found")}, nil)+ return+ }RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: err}, nil)return}