foundryvtt-cli
foundryvtt-cli copied to clipboard
pack generates error when doc contains "effects"
When attempting to perform a pack operation on a document that includes active effects, the pack operation aborts with an error. See sample here:
$ fvtt package pack hmk-possessions -v --type System --id hmk -t Item --in ~/dev/github/HarnMaster-Kethira-FoundryVTT/packs/hmk-possessions/_source --out /tmp/stage-hmk/packs/
[classic-level] Packing "/Users/tomr/dev/github/HarnMaster-Kethira-FoundryVTT/packs/hmk-possessions/_source" into "/tmp/stage-hmk/packs/hmk-possessions"
Packed M4nHcUWOatfVGuh3 (Armor)
Packed 3V8dQgPspKX32aUw (Armor Traits)
Failed to parse /Users/tomr/dev/github/HarnMaster-Kethira-FoundryVTT/packs/hmk-possessions/_source/arrow__heavy_bodkin_P3LMGDmP8tYLEbAb.json. See error below.
ModuleError: Key cannot be null or undefined
at ClassicLevel._checkKey (/Users/tomr/dev/github/foundryvtt-cli/node_modules/abstract-level/abstract-level.js:780:14)
at DefaultChainedBatch.put (/Users/tomr/dev/github/foundryvtt-cli/node_modules/abstract-level/abstract-chained-batch.js:41:25)
at file:///Users/tomr/dev/github/foundryvtt-cli/lib/package.mjs:243:11
at async apply (file:///Users/tomr/dev/github/foundryvtt-cli/lib/package.mjs:410:24)
at async apply (file:///Users/tomr/dev/github/foundryvtt-cli/lib/package.mjs:414:52)
at async compileClassicLevel (file:///Users/tomr/dev/github/foundryvtt-cli/lib/package.mjs:253:7)
at async handlePack (file:///Users/tomr/dev/github/foundryvtt-cli/commands/package.mjs:418:5)
at async Object.handler (file:///Users/tomr/dev/github/foundryvtt-cli/commands/package.mjs:124:22) {
code: 'LEVEL_INVALID_KEY'
The offending document is attached here: arrow__heavy_bodkin_P3LMGDmP8tYLEbAb.json
The problem seems to be in foundryvtt-cli/lib/package.mjs
line 414, where it is going through each item in the effects array. It is recursively calling the apply
function, but that assumes the first entry is a document. In fact, in the case of an effect, that first entry is a string, not an object. So, it subsequently fails when trying to find the "_key" element.