drawdb icon indicating copy to clipboard operation
drawdb copied to clipboard

Failed to construct 'URL': Invalid URL

Open ZX828 opened this issue 4 months ago • 15 comments

Subject: Import Failure: "Failed to construct 'URL'" Error with Valid Exported JSON​​

​​Description:​​

I am encountering an import error when trying to re-import a JSON file that was previously exported from DrawDB.

​​Error Message:​​

Uncaught (in promise) TypeError: Failed to construct 'URL': Invalid URL at Object.resolveUrl2 [as resolveUrl] (jsonschema.js?v=852b6613:324:39) at Validator2.validate (jsonschema.js?v=852b6613:1138:26) at jsonDiagramIsValid (validateSchema.js:5:26) at loadJsonData (ImportDiagram.jsx:54:12) at reader.onload (ImportDiagram.jsx:173:49) ​​Problem Details:​​

The JSON file was originally exported from DrawDB and has not been manually modified.

The file validates as correct JSON syntax through external validators (JSONLint).

​​Crucially, the JSON file contains no explicit URL fields​​ (e.g., no url, host, ip, or linkfields), which makes the error puzzling.

The error occurs during the JSON Schema validation step (jsonschema.js), suggesting an internal validation rule may be incorrectly applied to a non-URL data field.

​​Steps to Reproduce:​​

Export a diagram to JSON from DrawDB.

Attempt to re-import the same JSON file.

The import fails with the above error.

​​Request:​​

Could you please investigate why the JSON Schema validator is attempting to parse a non-URL field as a URL? This appears to be a bug where a validation rule for "format": "uri"is being triggered by standard data.

Thank you for your assistance.

ZX828 avatar Aug 25 '25 01:08 ZX828

can u please share an example where the issue occurs

1ilit avatar Aug 25 '25 05:08 1ilit

1.Create a new MySQL table relationship

Image

2.Export as a JSON file

Image

3.Create New and Import the newly created JSON file

Image Image

ZX828 avatar Aug 26 '25 04:08 ZX828

Can I work on this issue

MeetD99 avatar Aug 29 '25 21:08 MeetD99

Thanks for your interest! I'm just the one who raised the issue, so I'll let the maintainers decide. @1ilit

ZX828 avatar Aug 31 '25 07:08 ZX828

@MeetD99 sure

1ilit avatar Aug 31 '25 08:08 1ilit

@ZX828 the import seems to work correctly for me, has this already been fixed? @1ilit

MeetD99 avatar Sep 02 '25 17:09 MeetD99

haven't fixed it and cant reproduce it either. can you attach the json youre trying to import

1ilit avatar Sep 03 '25 06:09 1ilit

https://www.drawdb.app/editor I created a new table relationship on the page https://www.drawdb.app/editor and then exported a .json file. Then, I opened a new page and tried to import the .json file I just exported, but the import button was unavailable. Image

ZX828 avatar Sep 09 '25 16:09 ZX828

Still works perfectly for me, can you share a sreen recorded video, please? @ZX828

MeetD99 avatar Sep 12 '25 18:09 MeetD99

https://github.com/user-attachments/assets/d3b46319-17b1-409f-9aea-b57739afd20d

ZX828 avatar Sep 16 '25 11:09 ZX828

@MeetD99

ZX828 avatar Sep 16 '25 11:09 ZX828

Hi @1ilit @MeetD99, I'd like to help investigate this issue. I can see it's been challenging to reproduce. I have some ideas about the JSON schema validation that might help. Would it be okay if I take a look at the code and share my findings?

7vignesh avatar Oct 02 '25 20:10 7vignesh

@7vignesh yeah please go ahead

1ilit avatar Oct 03 '25 06:10 1ilit

Hi @1ilit,

Sorry for the confusion - I created some orphaned commits (328cebc, 7ef42eb, fe7fbbd) while testing issue #561. Could you clean them up when you get a chance?

7vignesh avatar Oct 03 '25 13:10 7vignesh

Hi @1ilit, I’ve already fixed this issue locally — could you please assign it to me so I can open the PR?

khushthecoder avatar Nov 15 '25 20:11 khushthecoder