Skip to content

Commit

Permalink
Improve error message in public api, fix public api typing (#9086)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraggle authored Dec 3, 2024
1 parent e6fc57f commit f363ccf
Show file tree
Hide file tree
Showing 24 changed files with 64 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
5 changes: 3 additions & 2 deletions front/pages/api/v1/w/[wId]/assistant/conversations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down Expand Up @@ -156,7 +157,7 @@ async function handler(
}

let conversation = await createConversation(auth, {
title,
title: title ?? null,
visibility,
});

Expand Down
3 changes: 2 additions & 1 deletion front/pages/api/v1/w/[wId]/data_source_views/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid query parameters: ${r.error.message}`,
message: "Invalid query parameters.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
3 changes: 2 additions & 1 deletion front/pages/api/v1/w/[wId]/files/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
3 changes: 2 additions & 1 deletion front/pages/api/v1/w/[wId]/members/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${parsing.error.message}`,
message: "Invalid request body.",
request_format_errors: parsing.error.flatten(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
4 changes: 0 additions & 4 deletions front/pages/api/v1/w/[wId]/swagger_schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@
* required:
* - username
* - timezone
* - fullName
* - email
* - profilePictureUrl
* - origin
* properties:
* username:
* type: string
Expand Down
3 changes: 2 additions & 1 deletion front/pages/api/v1/w/[wId]/workspace-usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
3 changes: 2 additions & 1 deletion front/pages/api/w/[wId]/data_sources/[dsId]/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ async function handler(
status_code: 400,
api_error: {
type: "invalid_request_error",
message: `Invalid request body: ${r.error.message}`,
message: "Invalid request body.",
request_format_errors: r.error.flatten(),
},
});
}
Expand Down
28 changes: 17 additions & 11 deletions front/public/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@
"favorites"
]
}
},
{
"in": "query",
"name": "includes",
"required": false,
"description": "Array of additional data to include in the response",
"schema": {
"type": "array",
"items": {
"type": "string",
"enum": [
"authors"
]
}
}
}
],
"security": [
Expand Down Expand Up @@ -3133,17 +3148,12 @@
"properties": {
"name": {
"type": "string",
"description": "Name of the table",
"deprecated": true
"description": "Name of the table"
},
"title": {
"type": "string",
"description": "Title of the table"
},
"mime_type": {
"type": "string",
"description": "Mime type of the table"
},
"table_id": {
"type": "string",
"description": "Unique identifier for the table"
Expand Down Expand Up @@ -3547,11 +3557,7 @@
"type": "object",
"required": [
"username",
"timezone",
"fullName",
"email",
"profilePictureUrl",
"origin"
"timezone"
],
"properties": {
"username": {
Expand Down
7 changes: 5 additions & 2 deletions sdks/js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1661,8 +1661,11 @@ export type PublicPostContentFragmentRequestBody = z.infer<

export const PublicPostConversationsRequestBodySchema = z.intersection(
z.object({
title: z.string().nullable(),
visibility: z.enum(["unlisted", "workspace", "deleted", "test"]),
title: z.string().nullable().optional(),
visibility: z
.enum(["unlisted", "workspace", "deleted", "test"])
.optional()
.default("unlisted"),
message: z.union([
z.intersection(
z.object({
Expand Down
1 change: 1 addition & 0 deletions types/src/front/lib/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export type APIErrorType =
export type APIError = {
type: APIErrorType;
message: string;
request_format_errors?: object;
data_source_error?: CoreAPIError;
run_error?: CoreAPIError;
app_error?: CoreAPIError;
Expand Down

0 comments on commit f363ccf

Please sign in to comment.