Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error thrown when calling actor.prepareData() #4915

Open
caewok opened this issue Dec 21, 2024 · 0 comments
Open

Error thrown when calling actor.prepareData() #4915

caewok opened this issue Dec 21, 2024 · 0 comments

Comments

@caewok
Copy link
Contributor

caewok commented Dec 21, 2024

FoundryVTT 12.331
dnd5e 4.1.2
Chrome v131.0.6778.140.
No modules.

Calling prepareData on an actor whose token is placed on the canvas throws an error. For example:

_token.actor.prepareData()
base-activity.mjs:563 Uncaught TypeError: Cannot redefine property: _inferredSource
    at Function.defineProperty (<anonymous>)
    at CheckActivity.prepareFinalData (base-activity.mjs:563:12)
    at CheckActivity.prepareFinalData (check-data.mjs:64:11)
    at ToolData.prepareFinalActivityData (activities.mjs:299:56)
    at ToolData.prepareFinalData (tool.mjs:123:10)
    at Item5e.prepareFinalAttributes (item.mjs:670:33)
    at actor.mjs:200:37
    at EmbeddedCollection.forEach (foundry-esm.js:5031:9)
    at Actor5e.prepareData (actor.mjs:200:16)
    at <anonymous>:1:14

Same for NPCs:

_token.actor.prepareData()
source-field.mjs:105 Uncaught TypeError: Cannot redefine property: source
    at Function.defineProperty (<anonymous>)
    at NPCData.shimActor (source-field.mjs:105:12)
    at NPCData.prepareBaseData (npc.mjs:324:27)
    at Actor5e.prepareData (foundry.js:10820:37)
    at Actor5e.prepareData (foundry.js:15863:11)
    at Actor5e.prepareData (flags.mjs:21:11)
    at Actor5e.prepareData (actor.mjs:199:11)
    at <anonymous>:1:14

This seems to happen when prepareFinalAttributes is called on an item with activities that were copied from an existing one (ie a cloned item).

This appears to be an error because I would expect prepareData to be idempotent and, if the data need not be prepared, it should just return. I would also expect prepareData to trigger an update if data has changed that has not yet been accounted for.

This behavior is different than what was seen in dnd5e v3. (No error was thrown in this situation.)

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

No branches or pull requests

1 participant