drawdb icon indicating copy to clipboard operation
drawdb copied to clipboard

fix: prevent crash on invalid URI during JSON import (#561)

Open khushthecoder opened this issue 1 month ago • 5 comments

This PR fixes issue #561.

The JSON import flow was crashing because the default uri format validator inside jsonschema throws a TypeError when given an empty string or a non-URL-safe value.

This patch adds a safe custom URI validator (safeUriValidator) and overrides the built-in uri format.
It allows empty strings, trims input, and returns false instead of throwing — preventing the app from crashing.

Tested locally: ✓ Export JSON ✓ Re-import JSON in a fresh editor tab ✓ No errors, import works correctly

Thanks!

khushthecoder avatar Nov 15 '25 20:11 khushthecoder

@khushthecoder is attempting to deploy a commit to the dottle's projects Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Nov 15 '25 20:11 vercel[bot]

@khushthecoder can u please provide a diagram where the error occurs

1ilit avatar Nov 16 '25 11:11 1ilit

@khushthecoder can u please provide a diagram where the error occurs

sure will do it in a few moments

khushthecoder avatar Nov 16 '25 11:11 khushthecoder

image Hi @l1lit, As requested, I've successfully reproduced the original bug on my local machine. I ran the code from the upstream/main branch (on the bug-repro-branch) and imported the original .json file from issue #561. Here is the screenshot of the console crash (TypeError: Invalid URL). My PR correctly handles this exact error and prevents the app from crashing.

khushthecoder avatar Nov 16 '25 17:11 khushthecoder

please export the diagram as json and attach it here

1ilit avatar Nov 16 '25 19:11 1ilit