Editing any item with a "Resource" causes Foundry to lock up

Issue #270 resolved
Leone Shamoth created an issue

I just updated everything to the most recent version, with FoundryVTT at version 0.8.8 and Obsidian at version 5.0.5.

When I try to modify any item that has an effect with a “resource” (i.e. Consumes resource, produces resource, add resource), Foundry completely locks up, requiring the website to be refreshed. This extends to the consumable item type, which upon just adding one to the character sheet causes Foundry to entirely lock up.

Looking at the console, this is the error I see when I do the above actions

Comments (4)

  1. Leone Shamoth reporter

    I should expand this, as it does not simply apply to items. I have just now tested with spells and abilities consuming resources, and the same problem happens.

  2. Ben Freeland

    It looks like this is because in js/sheets/effect.js the getData() method assumes that all consume and produce effects target an item or a feature:

    if (data.actor) {
        item =
            data.actor.items.get(
                component.target === 'feat' ? component.featID : component.itemID)
                .toObject(false);
    }
    

    If the item has an effect with consume or produce set to spell slots or quantity this will cause an exception. I was able to work around this by changing the block to the following:

    if (data.actor && ((component.target === 'feat') || (!OBSIDIAN.notDefinedOrEmpty(component.itemID)))) {
        item =
            data.actor.items.get(
                component.target === 'feat' ? component.featID : component.itemID)
                .toObject(false);
    }
    

    I dunno if that’s the best fix, but it avoids the exception.

  3. Kim Mantas repo owner

    I think this is normally ok because component.itemID usually gets initialised to an existing item when you create the component (and indeed I can’t reproduce this). Regardless, as Ben pointed out, the code is definitely not correct so I’ll put out a fix for that soon.

  4. Log in to comment