fix: handle URL construction error when switching to Visual Editor#35004
Merged
crazywoola merged 2 commits intolanggenius:mainfrom Apr 13, 2026
Merged
Conversation
crazywoola
previously approved these changes
Apr 13, 2026
The jsonschema library may throw "Failed to construct 'URL': Invalid URL" in browser environments when resolving schema $id URIs internally. This error was uncaught in draft07Validator, causing it to propagate up and block the tab switch from JSON Schema to Visual Editor. Catch the error gracefully and return empty validation errors, since structural schema validation is already handled by preValidateSchema. Closes langgenius#34841 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
777e78d to
a1c5140
Compare
crazywoola
approved these changes
Apr 13, 2026
HanqingZ
pushed a commit
to HanqingZ/dify
that referenced
this pull request
Apr 23, 2026
…anggenius#35004) Co-authored-by: Sami Rusani <sr@samirusani> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
jsonschemalibrary'sValidator.validate()internally callsnew URL()for URI resolution of schema$idreferences, which can throw"Failed to construct 'URL': Invalid URL"in browser environments. This uncaught error propagated up tohandleTabChange, where it was caught as a parse error — blocking the switch from JSON Schema to Visual Editor.Added a try-catch in
draft07Validator(web/utils/validators.ts) to handle this gracefully, returning empty validation errors on failure since structural schema validation is already covered bypreValidateSchema.Fixes #34841
Screenshots
N/A — the fix restores expected behavior (tab switching works without errors).
Checklist
make lintandmake type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint godsFrom Claude Code