Skip to content

fix: detect .json files in IFCLoader.load() with helpful error message#195

Open
TeapoyY wants to merge 1 commit intoThatOpen:mainfrom
TeapoyY:fix/json-load-error
Open

fix: detect .json files in IFCLoader.load() with helpful error message#195
TeapoyY wants to merge 1 commit intoThatOpen:mainfrom
TeapoyY:fix/json-load-error

Conversation

@TeapoyY
Copy link
Copy Markdown

@TeapoyY TeapoyY commented Apr 6, 2026

Summary

When users attempt to load a .json file (produced by the ifc-to-json tool) using IFCLoader.load(), the loader previously attempted to parse it as a binary IFC file, resulting in a cryptic "File too small" error from web-ifc with no context about what went wrong.

This PR adds detection of .json URLs at the start of the load() method and throws a clear, actionable error message explaining the limitation and the correct workflow.

The Bug

Issue: #136

Users converting IFC files to JSON using the ifc-to-json tool then trying to load the .json file directly via loadAsync(url) get an opaque error dialog "File too small" with no guidance on how to resolve it.

The Fix

In IFCLoader.load(), before loading, check if the URL ends with .json. If so, immediately invoke the error callback (or console.error) with a helpful message that:

  1. Explains that .json files cannot be loaded directly
  2. Notes that JSON files from ifc-to-json only contain property/metadata (not geometry)
  3. Points users to addModelJSONData() for loading property data alongside an IFC file
  4. Links to the official documentation

Bounty

This PR addresses #136 (labeled: bounty)

… message

Previously, when a user tried to load a JSON file (produced by the
ifc-to-json tool) using IFCLoader.load(), the loader would attempt
to parse it as a binary IFC file, resulting in a cryptic 'File too
small' error from web-ifc.

This change adds detection of .json URLs at the start of the load()
method and throws a clear, actionable error message explaining:
1. That .json files cannot be loaded directly
2. That JSON files from ifc-to-json only contain property data,
   not geometry
3. That users should load the IFC file normally and then use
   addModelJSONData() for property data
4. A link to the documentation for the correct workflow

Fixes ThatOpen#136 (bounty)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant