rojo-rbx / remodel

Scriptable Roblox multitool: Manipulate instances, model files, places, and assets on Roblox.com
MIT License
169 stars 38 forks source link

"Unexpected token inside qualified name: !:" from remodel.readModelAsset #20

Closed unix-system closed 3 years ago

unix-system commented 4 years ago

When running the following line:

local model_root = remodel.readModelAsset(rbxmx_path)
[ERROR] callback error: external error: line 1, column 0: 1:8 Unexpected token inside qualified name: !: stack traceback:
                [C]: in ?
                [C]: in field 'readModelAsset'
                [string "vet.lua"]:45: in main chunk

        Caused by:
            0: external error: line 1, column 0: 1:8 Unexpected token inside qualified name: !
            1: line 1, column 0: 1:8 Unexpected token inside qualified name: !
            2: 1:8 Unexpected token inside qualified name: !

This error seems to sometimes resolve itself - I have no idea what causes it - the value for rbxmx_path is a valid assetId string, and sometimes I don't change the code and it just happens. I can't debug it any further because the stack trace is super cryptic.

I'm using the latest version of remodel from Foreman.

unix-system commented 4 years ago

The root cause of this is remodel.rs, line 193 https://github.com/Roblox/remodel/blob/aed432ce0557bbbda693301063964bb5bc40db97/src/remodel_api/remodel.rs#L193

Looks like it's trying to decode the binary file (as most uploaded models are binary format, not XML)

There are two solutions I can think of:

  1. (Hotfix) change it to binary tree decoder
  2. (Permanent fix) identify magic bytes at the start of the file - if it's an rbxm, then binary, if it's rbxmx, then XML decode

I'll fork it and work on it - will keep people updated and make a PR, but due to the current state of this project I expect it to take a while to get approved.

unix-system commented 4 years ago

Also - as another point, perhaps we could make the error messages more specific? The error provided is cryptic and doesn't narrow it down to the decoder (the cause of this issue is because it hits the ! in the <!roblox magic bytes.

LPGhatguy commented 3 years ago

Fixed in commit 3319bc30f0ec0f1f12bc231cf22b70f437fa8582.