Skip to content

PhysicalItemTemplate#asGear() fails if the compendium source item has been deleted #6934

Description

@Aioros
  1. Create an item in a compendium;
  2. Give it to an NPC (should be added as gear);
  3. Delete the original item from the compendium;
  4. call asGear() on the item, or getGear() on the actor.

Seems like in this section of asGear() the check on item should happen before trying to get its name.

if ( this.metadata.compendiumGearSource && this.parent._stats.compendiumSource && (flags.preserve !== true) ) {
  const item = await fromUuid(this.parent._stats.compendiumSource);
  const name = (flags.preserveName === true ? this.parent._source.name : flags.preserveName) ?? item.name;
  if ( item ) clone = item.clone({ ...change, name, "system.quantity": this.quantity }, { keepId: true });
}

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions