From f4c6cdab3bddb46ed14fe87b5774badd4749e7d8 Mon Sep 17 00:00:00 2001 From: ewandor Date: Thu, 1 May 2025 19:34:40 +0200 Subject: [PATCH] More explicit schema provider error when resource is not found --- gui/rpk-gui/src/lib/crud/providers/jsonschema-provider.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gui/rpk-gui/src/lib/crud/providers/jsonschema-provider.tsx b/gui/rpk-gui/src/lib/crud/providers/jsonschema-provider.tsx index 5b74ad0..17cf378 100644 --- a/gui/rpk-gui/src/lib/crud/providers/jsonschema-provider.tsx +++ b/gui/rpk-gui/src/lib/crud/providers/jsonschema-provider.tsx @@ -59,10 +59,12 @@ function convertCamelToSnake(str: string): string { } function buildResource(rawSchemas: RJSFSchema, resourceName: string) { - let resource; + if (rawSchemas.components.schemas[resourceName] === undefined) { + throw new Error(`Resource "${resourceName}" not found in schema.`); + } const shortResourceName = convertCamelToSnake(resourceName.replace(/(-Input|Create|Update)$/g, "")); - resource = structuredClone(rawSchemas.components.schemas[resourceName]); + let resource = structuredClone(rawSchemas.components.schemas[resourceName]); resource.components = { schemas: {} }; for (let prop_name in resource.properties) { let prop = resource.properties[prop_name];