#PF2 System Data Model Bug
1 messages · Page 1 of 1 (latest)
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
I just want working API docs 😢
things will settle down a little bit post stable release and let the dev team pivot toward api documentation
would appreciate that greatly
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.
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()
}
its crashing in foundry core code, unlikely
its before the data models are instantiated
I am now free and can start checking
good point if it's world load then lets check module.json
"documentTypes": {
"Actor": {
"organization": {
"htmlFields": ["features", "powers"]
},
"warfare": {}
}
},
the day 12.323 came out
okay, so that's fine
confirmed crashes in 5e as well
module.json?
{
"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
yeah
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
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.
Ah from the static properties
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 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
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.
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
(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
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
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.