From 465e07de838b24671d787de5a2cc0b8b0fd37c9d Mon Sep 17 00:00:00 2001 From: Vikrant Gupta Date: Mon, 23 Feb 2026 16:47:24 +0530 Subject: [PATCH] fix(openapi): make the error and status as mandatory (#10391) * fix(openapi): make the error and status as mandatory * fix(openapi): fix the frontend types --- docs/api/openapi.yml | 6 ++++++ frontend/src/api/generated/services/sigNoz.schemas.ts | 8 ++++---- frontend/src/container/ForgotPassword/index.tsx | 4 +++- .../IngestionSettings/MultiIngestionSettings.tsx | 2 +- .../IngestionDetails/IngestionDetails.tsx | 6 +++--- .../container/OrganizationSettings/AuthDomain/index.tsx | 2 +- pkg/errors/http.go | 4 ++-- pkg/http/render/render.go | 4 ++-- 8 files changed, 22 insertions(+), 14 deletions(-) diff --git a/docs/api/openapi.yml b/docs/api/openapi.yml index bc2a255cd7..2f66818a3c 100644 --- a/docs/api/openapi.yml +++ b/docs/api/openapi.yml @@ -326,6 +326,9 @@ components: type: string url: type: string + required: + - code + - message type: object ErrorsResponseerroradditional: properties: @@ -1661,6 +1664,9 @@ components: $ref: '#/components/schemas/ErrorsJSON' status: type: string + required: + - status + - error type: object RoletypesGettableResources: properties: diff --git a/frontend/src/api/generated/services/sigNoz.schemas.ts b/frontend/src/api/generated/services/sigNoz.schemas.ts index 59d1f78a7e..9ee79ae687 100644 --- a/frontend/src/api/generated/services/sigNoz.schemas.ts +++ b/frontend/src/api/generated/services/sigNoz.schemas.ts @@ -436,7 +436,7 @@ export interface ErrorsJSONDTO { /** * @type string */ - code?: string; + code: string; /** * @type array */ @@ -444,7 +444,7 @@ export interface ErrorsJSONDTO { /** * @type string */ - message?: string; + message: string; /** * @type string */ @@ -1985,11 +1985,11 @@ export enum Querybuildertypesv5VariableTypeDTO { text = 'text', } export interface RenderErrorResponseDTO { - error?: ErrorsJSONDTO; + error: ErrorsJSONDTO; /** * @type string */ - status?: string; + status: string; } /** diff --git a/frontend/src/container/ForgotPassword/index.tsx b/frontend/src/container/ForgotPassword/index.tsx index 799e35168b..8168b7a144 100644 --- a/frontend/src/container/ForgotPassword/index.tsx +++ b/frontend/src/container/ForgotPassword/index.tsx @@ -48,7 +48,9 @@ function ForgotPassword({ } try { - ErrorResponseHandlerV2(mutationError as AxiosError); + ErrorResponseHandlerV2( + (mutationError as unknown) as AxiosError, + ); } catch (apiError) { return apiError as APIError; } diff --git a/frontend/src/container/IngestionSettings/MultiIngestionSettings.tsx b/frontend/src/container/IngestionSettings/MultiIngestionSettings.tsx index c3eb5f507e..07fe440ec5 100644 --- a/frontend/src/container/IngestionSettings/MultiIngestionSettings.tsx +++ b/frontend/src/container/IngestionSettings/MultiIngestionSettings.tsx @@ -342,7 +342,7 @@ function MultiIngestionSettings(): JSX.Element { useEffect(() => { if (isError) { - showErrorNotification(notifications, error as AxiosError); + showErrorNotification(notifications, (error as unknown) as AxiosError); } }, [error, isError, notifications]); diff --git a/frontend/src/container/OnboardingV2Container/IngestionDetails/IngestionDetails.tsx b/frontend/src/container/OnboardingV2Container/IngestionDetails/IngestionDetails.tsx index 95e86642f6..6b55149106 100644 --- a/frontend/src/container/OnboardingV2Container/IngestionDetails/IngestionDetails.tsx +++ b/frontend/src/container/OnboardingV2Container/IngestionDetails/IngestionDetails.tsx @@ -86,9 +86,9 @@ export default function OnboardingIngestionDetails(): JSX.Element {
{' '} - {(error as AxiosError)?.response?.data?.error - ?.message || - (error as AxiosError)?.message || + {((error as unknown) as AxiosError)?.response + ?.data?.error.message || + ((error as unknown) as AxiosError)?.message || 'Something went wrong'} diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/index.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/index.tsx index 0d16df8cc0..f5da31466b 100644 --- a/frontend/src/container/OrganizationSettings/AuthDomain/index.tsx +++ b/frontend/src/container/OrganizationSettings/AuthDomain/index.tsx @@ -110,7 +110,7 @@ function AuthDomain(): JSX.Element { let errorResult: APIError | null = null; try { ErrorResponseHandlerV2( - errorFetchingAuthDomainListResponse as AxiosError, + (errorFetchingAuthDomainListResponse as unknown) as AxiosError, ); } catch (error) { errorResult = error as APIError; diff --git a/pkg/errors/http.go b/pkg/errors/http.go index adc2fff22e..25a77fc40f 100644 --- a/pkg/errors/http.go +++ b/pkg/errors/http.go @@ -6,8 +6,8 @@ import ( ) type JSON struct { - Code string `json:"code"` - Message string `json:"message"` + Code string `json:"code" required:"true"` + Message string `json:"message" required:"true"` Url string `json:"url,omitempty"` Errors []responseerroradditional `json:"errors,omitempty"` } diff --git a/pkg/http/render/render.go b/pkg/http/render/render.go index 505563bb74..c0d0fb793b 100644 --- a/pkg/http/render/render.go +++ b/pkg/http/render/render.go @@ -21,8 +21,8 @@ type SuccessResponse struct { } type ErrorResponse struct { - Status string `json:"status"` - Error *errors.JSON `json:"error"` + Status string `json:"status" required:"true"` + Error *errors.JSON `json:"error" required:"true"` } func Success(rw http.ResponseWriter, httpCode int, data interface{}) {