p4535992 / foundryvtt-variant-encumbrance-dnd5e

A FoundryVTT module, providing a visual modification to player character sheets to better display the effects of the Encumbrance variant ruleset in the PHB.
MIT License
3 stars 4 forks source link

[BUG] Crash when using long-form property names in conjunction with pre-defined ID #32

Closed TheGiddyLimit closed 6 months ago

TheGiddyLimit commented 6 months ago

Module Version: v0.14.3

There are two errors at play here:

To Reproduce

(async () => {
    const act = await Actor.create({name: "Repro", type: "character"});

    await act.sheet.render(true);

    await new Promise(res => setTimeout(res, 200)); // Increase timeout as required -- this reliably repro'd for me

    const itemId = foundry.utils.randomID();

    await act.createEmbeddedDocuments(
        "Item",
        [
            {
                "_id": itemId,
                "name": "Test",
                "type": "loot",
                "system.description.value": "test",
            }
        ],
        {
            keepId: true,
        },
    );

    await act.updateEmbeddedDocuments(
        "Item",
        [
            {
                "_id": itemId,
                "system.description.value": "test2",
            }
        ]
    )
})();

Expected behavior

No crash on using the above (perfectly Foundry-valid) embed create/updates

Logs:

commons.js:8807 Foundry VTT | Created Actor with id [79A97cl9ONj9PMu4]
foundry.js:5802 Foundry VTT | Rendering ActorSheet5eCharacter
foundry.js:7682 Foundry VTT | Retrieved and compiled template systems/dnd5e/templates/actors/character-sheet.hbs
module.js:7109 DEBUG | variant-encumbrance-dnd5e | Actor 'Repro' : 0 / 50 = 0 => 0 []
module.js:7109 DEBUG | variant-encumbrance-dnd5e | Actor 'Repro' => 0 []
module.js:7109 DEBUG | variant-encumbrance-dnd5e | {"totalWeight":0,"totalWeightToDisplay":0,"lightMax":50,"mediumMax":100,"heavyMax":150,"encumbranceTier":0,"speedDecrease":0,"unit":"lbs.","encumbrance":{"value":0,"max":10,"pct":0,"encumbered":false},"mapItemEncumbrance":{}} []
module.js:7109 DEBUG | variant-encumbrance-dnd5e | Actor 'Repro' : 0 / 50 = 0 => 0 []
module.js:7109 DEBUG | variant-encumbrance-dnd5e | Actor 'Repro' => 0 []
module.js:7109 DEBUG | variant-encumbrance-dnd5e | {"totalWeight":0,"totalWeightToDisplay":0,"lightMax":50,"mediumMax":100,"heavyMax":150,"encumbranceTier":0,"speedDecrease":0,"unit":"lbs.","encumbrance":{"value":0,"max":10,"pct":0,"encumbered":false},"mapItemEncumbrance":{}} []
VM167733:9 ID is h9UdbbsO48faVABB
module.js:7237 Uncaught (in promise) ReferenceError: error is not defined
    at VariantEncumbranceDnd5eHelpers.prepareInventoryItemsFromUpdate (module.js:7237:13)
    at Object._updateEncumbranceInternal (module.js:10084:59)
    at Object.updateEncumbrance (module.js:10077:38)
    at Item5e.createDocuments (module.js:9795:36)
    at 🎁call_wrapper [as call_wrapper] (lib-wrapper.js:1:37561)
    at 🎁CONFIG.Item.documentClass.createDocuments#0 (lib-wrapper.js:1:32817)
    at Actor5e.createEmbeddedDocuments (commons.js:8215:18)
    at <anonymous>:11:12
prepareInventoryItemsFromUpdate @ module.js:7237
_updateEncumbranceInternal @ module.js:10084
updateEncumbrance @ module.js:10077
createDocuments @ module.js:9795
🎁call_wrapper @ lib-wrapper.js:1
🎁CONFIG.Item.documentClass.createDocuments#0 @ lib-wrapper.js:1
createEmbeddedDocuments @ commons.js:8215
(anonymous) @ VM167733:11
await in (anonymous) (async)
(anonymous) @ VM167733:35

Browser: Chrome

Foundry Version: 11.315

Game System: dnd5e 2.4.1

p4535992 commented 6 months ago

i'll fix right away

p4535992 commented 6 months ago

should be fixed (or at least patched ) on 0.14.7