{"record":{"id":"f28eb51bf7b59cad","repo":"SigNoz/signoz","slug":"errorid-missing-from-params","errorCode":null,"errorMessage":"ErrorID missing from params","messagePattern":"ErrorID missing from params","errorType":"validation","errorClass":"model.ApiError","httpStatus":400,"severity":"warning","filePath":"pkg/query-service/app/clickhouseReader/reader.go","lineNumber":2342,"sourceCode":"\n\tif err != nil {\n\t\tr.logger.Error(\"Error in processing sql query\", errorsV2.Attr(err))\n\t\treturn 0, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf(\"error in processing sql query\")}\n\t}\n\n\treturn errorCount, nil\n}\n\nfunc (r *ClickHouseReader) GetErrorFromErrorID(ctx context.Context, queryParams *model.GetErrorParams) (*model.ErrorWithSpan, *model.ApiError) {\n\n\tctx = ctxtypes.NewContextWithCommentVals(ctx, map[string]string{\n\t\tinstrumentationtypes.TelemetrySignal:  telemetrytypes.SignalTraces.StringValue(),\n\t\tinstrumentationtypes.CodeNamespace:    \"clickhouse-reader\",\n\t\tinstrumentationtypes.CodeFunctionName: \"GetErrorFromErrorID\",\n\t})\n\tif queryParams.ErrorID == \"\" {\n\t\tr.logger.Error(\"errorId missing from params\")\n\t\treturn nil, &model.ApiError{Typ: model.ErrorBadData, Err: fmt.Errorf(\"ErrorID missing from params\")}\n\t}\n\tvar getErrorWithSpanReponse []model.ErrorWithSpan\n\n\tquery := fmt.Sprintf(\"SELECT errorID, exceptionType, exceptionStacktrace, exceptionEscaped, exceptionMessage, timestamp, spanID, traceID, serviceName, groupID FROM %s.%s WHERE timestamp = @timestamp AND groupID = @groupID AND errorID = @errorID LIMIT 1\", r.TraceDB, r.errorTable)\n\targs := []interface{}{clickhouse.Named(\"errorID\", queryParams.ErrorID), clickhouse.Named(\"groupID\", queryParams.GroupID), clickhouse.Named(\"timestamp\", strconv.FormatInt(queryParams.Timestamp.UnixNano(), 10))}\n\n\terr := r.db.Select(ctx, &getErrorWithSpanReponse, query, args...)\n\tr.logger.Info(query)\n\n\tif err != nil {\n\t\tr.logger.Error(\"Error in processing sql query\", errorsV2.Attr(err))\n\t\treturn nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf(\"error in processing sql query\")}\n\t}\n\n\tif len(getErrorWithSpanReponse) > 0 {\n\t\treturn &getErrorWithSpanReponse[0], nil\n\t} else {\n\t\treturn nil, &model.ApiError{Typ: model.ErrorNotFound, Err: fmt.Errorf(\"Error/Exception not found\")}","sourceCodeStart":2324,"sourceCodeEnd":2360,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/clickhouseReader/reader.go#L2324-L2360","documentation":"Returned by GetErrorFromErrorID when queryParams.ErrorID is an empty string. It is a client-side validation failure (model.ErrorBadData) raised before any ClickHouse query is executed.","triggerScenarios":"Calling the get-error-detail endpoint with a missing or empty errorId in the request, e.g. /api/v1/errors/ (empty ID segment) or a JSON body without errorID.","commonSituations":"Frontend constructing the URL from an unset field, API clients omitting errorId, integration tests passing empty structs, scripts with unpopulated params after refactors.","solutions":["Always supply a non-empty ErrorID in GetErrorParams","Validate the request at the API layer (reject empty errorId with 400 before reaching the reader)","Default-or-fail fast in callers: if you cannot resolve an errorId, skip the detail lookup","Add a test asserting errorId is set before calling GetErrorFromErrorID"],"exampleFix":"// before\nparams := &model.GetErrorParams{} // ErrorID empty -> ErrorID missing from params\n// after\nif queryParams.ErrorID == \"\" { return 400 \"errorId is required\" }\nparams := &model.GetErrorParams{ErrorID: \"abcdef123\", GroupID: \"...\", Timestamp: ts}","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(req.ErrorID) == \"\" { return 400, errors.New(\"errorId is required\") }\nparams := &model.GetErrorParams{ErrorID: req.ErrorID, GroupID: req.GroupID, Timestamp: req.Timestamp}","typeGuard":"func hasErrorID(p *model.GetErrorParams) bool { return p != nil && p.ErrorID != \"\" }","tryCatchPattern":"if apiErr, ok := err.(*model.ApiError); ok && apiErr.Typ == model.ErrorBadData { return 400, apiErr.Err }","preventionTips":["Validate required params at the HTTP handler before calling the reader","Return 400 for missing errorId instead of letting it reach ClickHouse","Add contract tests for empty-param cases"],"tags":["validation","signoz","missing-parameter","bad-request"],"backgroundTag":"missing-required-parameter","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}