Repository navigation
Conversation
…k handling - Parse plain-text string bodies in parseK8sStatusBody so admission webhook rejection messages (e.g. validatequeue constraint errors) are properly extracted instead of failing JSON parsing. - Avoid leaking raw multi-line ApiException debug dumps (HTTP-Code/Body/Headers) to user-facing UI toasts when status messages are missing. - Check both error.body and error.response.body as well as status codes gracefully. - Provide clean human-readable fallbacks for HTTP 401, 403, 500, and 503. - Add unit test suite validating parseK8sStatusBody, constraint formatters, and ApiException handling. Signed-off-by: Norway-02 <anshulkhetade02@gmail.com>
|
@Norway-02: The label(s) DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
cc @de6p @JesseStutler @kevin-wangzefeng for review when you have a moment. Thanks! |
What type of PR is this?
/kind bug
What this PR does / why we need it:
This PR enhances Kubernetes API error handling and admission webhook message parsing in
packages/trpc/server/utils/k8s-errors.ts:Plain-Text Webhook & Response Body Parsing:
parseK8sStatusBodypreviously attemptedJSON.parseon all string response bodies and returnednullupon failure. Kubernetes admission webhook rejections (such as Volcanovalidatequeueorvalidatejobwebhooks) and non-JSON server error responses are returned as plain-text strings. Because parsing failed, the webhook formatterformatAdmissionWebhookMessagewas completely bypassed.{ message: trimmed }so webhook constraint parsers (deserved[...] <= capability[...],deserved[...] >= guarantee[...]) can process and format them into plain, actionable language.Prevent Leaking Raw Debug Dumps into User Toasts:
@kubernetes/client-node'sApiExceptionclass generates a multi-line debugging string forerror.message(HTTP-Code: ...\nMessage: ...\nBody: ...\nHeaders: ...). Falling back toerror.messageleaked this entire HTTP header and body dump directly into dashboard UI toasts.ApiExceptionor starts withHTTP-Code:, returning clean, localized status messages instead.Robust Code & Body Extraction:
code,statusCode, andresponse.statusCode.error.bodyanderror.response.body.Unit Test Suite:
packages/trpc/server/utils/k8s-errors.test.tscovering JSON bodies, plain-text webhook rejections, constraint formatters, 404/409 handling, and standard HTTP error cases.Which issue(s) this PR fixes:
N/A
Special notes for your reviewer:
npx tsx --test packages/trpc/server/utils/k8s-errors.test.ts.Does this PR introduce a user-facing change?