Skip to content

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.

chore: json tags for error struct (#11886)

Tushar Vats7c3ac5b22196
diff --git a/docs/api/openapi.yml b/docs/api/openapi.yml
index 032fd0e66c..d53c2dae41 100644
--- a/docs/api/openapi.yml
+++ b/docs/api/openapi.yml
@@ -3803,15 +3803,12 @@ components:
type:
type: string
url:
- nullable: true
type: string
required:
- type
- code
- message
- - url
- errors
- - retry
- suggestions
type: object
ErrorsResponseerroradditional:
@@ -3827,7 +3824,6 @@ components:
- suggestions
type: object
ErrorsResponseretryjson:
- nullable: true
properties:
delay:
$ref: '#/components/schemas/TimeDuration'
diff --git a/frontend/src/api/generated/services/sigNoz.schemas.ts b/frontend/src/api/generated/services/sigNoz.schemas.ts
index 731b514740..466e231dff 100644
--- a/frontend/src/api/generated/services/sigNoz.schemas.ts
+++ b/frontend/src/api/generated/services/sigNoz.schemas.ts
@@ -2185,14 +2185,9 @@ export interface ErrorsResponseerroradditionalDTO {
suggestions: string[];
}
-export type ErrorsResponseretryjsonDTOAnyOf = {
+export interface ErrorsResponseretryjsonDTO {
delay: TimeDurationDTO;
-};
-
-/**
- * @nullable
- */
-export type ErrorsResponseretryjsonDTO = ErrorsResponseretryjsonDTOAnyOf | null;
+}
export interface ErrorsJSONDTO {
/**
@@ -2207,7 +2202,7 @@ export interface ErrorsJSONDTO {
* @type string
*/
message: string;
- retry: ErrorsResponseretryjsonDTO | null;
+ retry?: ErrorsResponseretryjsonDTO;
/**
* @type array
*/
@@ -2217,9 +2212,9 @@ export interface ErrorsJSONDTO {
*/
type: string;
/**
- * @type string,null
+ * @type string
*/
- url: string | null;
+ url?: string;
}
export interface AuthtypesOrgSessionContextDTO {
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelStatus/__tests__/utils.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelStatus/__tests__/utils.test.ts
index 7194e5a5d4..af23594a08 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelStatus/__tests__/utils.test.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelStatus/__tests__/utils.test.ts
@@ -30,7 +30,6 @@ describe('panelStatusFromError', () => {
{ message: 'missing aggregation', suggestions: [] },
{ message: 'bad filter', suggestions: [] },
],
- retry: null,
suggestions: [],
type: '',
});
@@ -59,7 +58,6 @@ describe('panelStatusFromError', () => {
message: 'y',
url: '',
errors: [],
- retry: null,
suggestions: [],
type: '',
},
diff --git a/pkg/errors/http.go b/pkg/errors/http.go
index 3ea5544f59..17cfbc5e21 100644
--- a/pkg/errors/http.go
+++ b/pkg/errors/http.go
@@ -7,12 +7,12 @@ import (
)
type JSON struct {
- Type string `json:"type" required:"true"`
- Code string `json:"code" required:"true"`
- Message string `json:"message" required:"true"`
- Url string `json:"url" required:"true" nullable:"true"`
+ Type string `json:"type" required:"true" nullable:"false"`
+ Code string `json:"code" required:"true" nullable:"false"`
+ Message string `json:"message" required:"true" nullable:"false"`
+ Url string `json:"url,omitempty" required:"false"`
Errors []responseerroradditional `json:"errors" required:"true" nullable:"false"`
- Retry *responseretryjson `json:"retry" required:"true" nullable:"true"`
+ Retry *responseretryjson `json:"retry,omitempty" required:"false"`
Suggestions []string `json:"suggestions" required:"true" nullable:"false"`
}
@@ -21,7 +21,7 @@ type responseretryjson struct {
}
type responseerroradditional struct {
- Message string `json:"message" required:"true"`
+ Message string `json:"message" required:"true" nullable:"false"`
Suggestions []string `json:"suggestions" required:"true" nullable:"false"`
}
diff --git a/pkg/http/render/render_test.go b/pkg/http/render/render_test.go
index a793df0cc4..3008079b2d 100644
--- a/pkg/http/render/render_test.go
+++ b/pkg/http/render/render_test.go
@@ -99,13 +99,13 @@ func TestError(t *testing.T) {
name: "AlreadyExists",
statusCode: http.StatusConflict,
err: errors.New(errors.TypeAlreadyExists, errors.MustNewCode("already_exists"), "already exists").WithUrl("https://already_exists"),
- expected: []byte(`{"status":"error","error":{"type":"already-exists","code":"already_exists","message":"already exists","url":"https://already_exists","errors":[],"retry":null,"suggestions":[]}}`),
+ expected: []byte(`{"status":"error","error":{"type":"already-exists","code":"already_exists","message":"already exists","url":"https://already_exists","errors":[],"suggestions":[]}}`),
},
"/unauthenticated": {
name: "Unauthenticated",
statusCode: http.StatusUnauthorized,
err: errors.New(errors.TypeUnauthenticated, errors.MustNewCode("not_allowed"), "not allowed").WithUrl("https://unauthenticated").WithAdditional("a1", "a2"),
- expected: []byte(`{"status":"error","error":{"type":"unauthenticated","code":"not_allowed","message":"not allowed","url":"https://unauthenticated","errors":[{"message":"a1","suggestions":[]},{"message":"a2","suggestions":[]}],"retry":null,"suggestions":[]}}`),
+ expected: []byte(`{"status":"error","error":{"type":"unauthenticated","code":"not_allowed","message":"not allowed","url":"https://unauthenticated","errors":[{"message":"a1","suggestions":[]},{"message":"a2","suggestions":[]}],"suggestions":[]}}`),
},
}
@@ -177,8 +177,7 @@ func TestErrorRetryAfterHeader(t *testing.T) {
name: "BareErrorNoHeaderNoRetryBlock",
err: errors.New(errors.TypeInternal, errors.MustNewCode("boom"), "boom"),
wantRetryAfter: "",
- wantBodyContains: `"retry":null`,
- wantBodyNotContains: `"delay"`,
+ wantBodyNotContains: `"retry"`, // omitempty drops the nil retry block entirely
},
}