#PF2 System Data Model Bug

1 messages · Page 1 of 1 (latest)

dawn garden
#

@wintry phoenix making a thread to help

fast flume
#

thank you both for this, put a "nath owes me a favour" card in your back pockets you can cash in at a future time

dawn garden
#

I just want working API docs 😢

fast flume
#

things will settle down a little bit post stable release and let the dev team pivot toward api documentation

dawn garden
#

would appreciate that greatly

wintry phoenix
#

sorry, I'm in multiple things at once. Can you post your module source code?

#

Basically on v12.323 I did this

#
class MinionModel extends foundry.abstract.TypeDataModel {
    static defineSchema() {
        const fields = foundry.data.fields;
        return {};
    }
}

class TreatModel extends foundry.abstract.TypeDataModel {
    static defineSchema() {
        const fields = foundry.data.fields;
        return {};
    }
}

Hooks.on("init", () => {
    foundry.utils.mergeObject(CONFIG.Actor.dataModels, {
        "test-companion-actor.minion": MinionModel,
    });

    foundry.utils.mergeObject(CONFIG.Item.dataModels, {
        "test-companion-actor.treat": TreatModel,
    });
})```
#

just to set it up

#

but the world won't load because its choking on prefixes.length === 0

#

let me try relaxing the system requirements and trying in 5e.

dawn garden
#

Yeah, my guess is there's something happening upstream in the pf2 source code

#

@wintry phoenix what happens if you add at least one field to each model, just a simple

return {
  myBool: new fields.BooleanField()
}
wintry phoenix
#

its crashing in foundry core code, unlikely

#

its before the data models are instantiated

#

I am now free and can start checking

dawn garden
#

good point if it's world load then lets check module.json

#

  "documentTypes": {
    "Actor": {
      "organization": {
        "htmlFields": ["features", "powers"]
      },
      "warfare": {}
    }
  },
wintry phoenix
#

this is where its crashing

dawn garden
#

wait basic question

#

when's the last time you did a fresh install of v12

wintry phoenix
#

the day 12.323 came out

dawn garden
#

okay, so that's fine

wintry phoenix
#

confirmed crashes in 5e as well

dawn garden
wintry phoenix
#
{
  "id": "test-companion-actor",
  "title": "Test-Companion-Actor",
  "version": "1.0.0",
  "compatibility": {
    "minimum": "12",
    "verified": "12"
  },
  "esmodules": ["main.mjs"],
  "languages": [{
    "lang": "en",
    "name": "English",
    "path": "en.json"
  }],
  "documentTypes": {
    "Actor": {
      "minion": {}
    },
    "Item": {
      "treat": {}
    }
  }
}```
#

this is a test module not solving a real problem

dawn garden
#

yeah

wintry phoenix
#

let me try your other things to test

#

adding a field does not help

#

can I see the source code for your module?

#

I have a suspicion

dawn garden
wintry phoenix
#

my guess was wrong, odd

#

wait

#

it might be me

#

mergeObject() might have been culling data.

#

100% it, that was it. Don't use mergeObject() to assign data models.

#

I forgot it kills such things.

dawn garden
#

Ah from the static properties

wintry phoenix
#

yeah exactly

#

Yeah I asked in feedback because I was certain either I did something wrong, or it was already known by now

#

because its kinda late in the 323 cycle so couldn't have been a new issue I think

#

seems my thoughts were well founded

fast flume
dawn garden
#

@fast flume given that there's possibly people using mergeObject for their classes it's probably worth it to fix that first line of Localization.#localizeSchema

#

so prefix?.length instead of prefixes.length

#

I can write a git issue if you want

fast flume
#

I am going to tell you straight up i have no idea what that means but please file a report explaining it on git and i will flag it for the dev team to review before we launch stable.

wintry phoenix
#

well, given it kills the world, I find it unlikely that anyone is going to publish such a module. We likely don't need to defend to that extent.

#

its not even situationally kills the world, its immediate

fast flume
#

(if you link it to me i'll throw it in the milestone for urgent review)

#

i really appreciate you both for taking the time to dig into this

dawn garden
tawdry hazel
#

I suppose it just needs some documentation that particularly the second object passed as an argument to mergeObject will be treated as a plain object

#

it'll be expanded if necessary, and then its entries will be recursively copied over

#

anything not enumerable via Object.entries won't be seen

wintry phoenix
#

Well, glad this is resolved. That said @dawn garden I tested your warfare module and the fixed version of my thing in D&D 3.2.0, which is a newer version than the one you screenshotted, so might want to be careful with that.

#

seems if there's no system.details in your data module it kabooms

#

Seems any initialization code in the base actor class is ripe for conflict.