Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(playground): show user-friendly toast notification for JSON prettification; do not report to sentry (#8957)

marliessophie7a2c5188cde3
diff --git a/web/src/features/playground/page/components/CreateOrEditLLMSchemaDialog.tsx b/web/src/features/playground/page/components/CreateOrEditLLMSchemaDialog.tsx
index 24df4e646d..f627b7b01e 100644
--- a/web/src/features/playground/page/components/CreateOrEditLLMSchemaDialog.tsx
+++ b/web/src/features/playground/page/components/CreateOrEditLLMSchemaDialog.tsx
@@ -31,6 +31,7 @@ import { api } from "@/src/utils/api";
import { JSONSchemaFormSchema, type LlmSchema } from "@langfuse/shared";
import { CodeMirrorEditor } from "@/src/components/editor";
+import { showErrorToast } from "@/src/features/notifications/showErrorToast";
const formSchema = z.object({
name: LLMSchemaNameSchema,
@@ -140,7 +141,11 @@ export const CreateOrEditLLMSchemaDialog: React.FC<
const prettified = JSON.stringify(parsedJson, null, 2);
form.setValue("schema", prettified);
} catch (error) {
- console.error("Failed to prettify JSON:", error);
+ showErrorToast(
+ "Failed to prettify JSON",
+ "Please verify your input is valid JSON",
+ "WARNING",
+ );
}
};
diff --git a/web/src/features/playground/page/components/CreateOrEditLLMToolDialog.tsx b/web/src/features/playground/page/components/CreateOrEditLLMToolDialog.tsx
index fb8122b9a7..914958ea3e 100644
--- a/web/src/features/playground/page/components/CreateOrEditLLMToolDialog.tsx
+++ b/web/src/features/playground/page/components/CreateOrEditLLMToolDialog.tsx
@@ -31,6 +31,7 @@ import { api } from "@/src/utils/api";
import { CodeMirrorEditor } from "@/src/components/editor";
import { JSONSchemaFormSchema, type LlmTool } from "@langfuse/shared";
+import { showErrorToast } from "@/src/features/notifications/showErrorToast";
const formSchema = z.object({
name: LLMToolNameSchema,
@@ -140,7 +141,11 @@ export const CreateOrEditLLMToolDialog: React.FC<CreateOrEditLLMToolDialog> = (
const prettified = JSON.stringify(parsedJson, null, 2);
form.setValue("parameters", prettified);
} catch (error) {
- console.error("Failed to prettify JSON:", error);
+ showErrorToast(
+ "Failed to prettify JSON",
+ "Please verify your input is valid JSON",
+ "WARNING",
+ );
}
};