Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: handle URL construction error when switching to Visual Editor (#35004)

Sam25a33a454cc3
diff --git a/web/utils/validators.ts b/web/utils/validators.ts
index 51b47feddf4..79d1bdc2744 100644
--- a/web/utils/validators.ts
+++ b/web/utils/validators.ts
@@ -1,11 +1,21 @@
-import type { Schema } from 'jsonschema'
+import type { Schema, ValidationError, ValidatorResult } from 'jsonschema'
import { Validator } from 'jsonschema'
import draft07Schema from './draft-07.json'
const validator = new Validator()
-export const draft07Validator = (schema: any) => {
- return validator.validate(schema, draft07Schema as unknown as Schema)
+type Draft07ValidationResult = Pick<ValidatorResult, 'valid' | 'errors'>
+
+export const draft07Validator = (schema: any): Draft07ValidationResult => {
+ try {
+ return validator.validate(schema, draft07Schema as unknown as Schema)
+ }
+ catch {
+ // The jsonschema library may throw URL errors in browser environments
+ // when resolving schema $id URIs. Return empty errors since structural
+ // validation is handled separately by preValidateSchema (#34841).
+ return { valid: true, errors: [] as ValidationError[] }
+ }
}
export const forbidBooleanProperties = (schema: any, path: string[] = []): string[] => {