Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

BattleTech - A Time of War character sheet - Data migration script causing multiple Type Error: t is undefined

Hi all, I'm working on a data migration script for the BattleTech - A Time of War character sheet. I've finished a major update to the character skills code, but I need to migrate all the old data over to the new attribute fields. Unfortunately, when I test my migration, I keep randomly getting a Type Error: t is undefined error, and apparently it's coming from base.js:20:2689 The number of times the error occurs seems to be random, and I can't work out where it's coming from or what's causing it. I wrapped my entire migration code in a try catch, and I'm still getting the error, so I'm wondering if it's a bug in Roll20? It could also be that I'm making too many getAttrs() and setAttrs() calls; I don't know if there's some kind of limit. Here's a sample of my console output: old skill values: {"repeating_skills_-lgc1qcsdtgqqidpgr-v_skill":"art","repeating_skills_-lgc1qcsdtgqqidpgr-v_skillNotes":"Oral Traditions - not learned","repeating_skills_-lgc1qcsdtgqqidpgr-v_skillXP":"0"} sheetsandboxworker.js:917:25 old sub skill type: string sheetsandboxworker.js:922:25 skill value: art sheetsandboxworker.js:930:25 skill data: {"linkedAttributes":["dexterity_link"],"targetNumber":8,"complexity":"CB","subSkills":true,"displayName":{"art":"Art"}} sheetsandboxworker.js:951:25 skill name: art sheetsandboxworker.js:990:25 TypeError: t is undefined base.js:20:2689 migrated skill data: {"repeating_skills_-lgc1qcsdtgqqidpgr-v_skill":"art","repeating_skills_-lgc1qcsdtgqqidpgr-v_sub_skill":"Oral Traditions - not learned","repeating_skills_-lgc1qcsdtgqqidpgr-v_skill_xp":"0"} sheetsandboxworker.js:996:25 old skill values: {"repeating_skills_-lgc1uy7xmtuytewmdtn_skill":"art","repeating_skills_-lgc1uy7xmtuytewmdtn_skillNotes":"Songwriting","repeating_skills_-lgc1uy7xmtuytewmdtn_skillXP":"20"} sheetsandboxworker.js:917:25 TypeError: t is undefined base.js:20:2689 old sub skill type: string sheetsandboxworker.js:922:25 TypeError: t is undefined base.js:20:2689 skill value: art Here's my migration code: <a href="https://github.com/Skater901/roll20-character-sheets/blob/BTATOW/BattleTech-A-Time-of-War/BattleTech-A-Time-of-War.html#L1566-L1672" rel="nofollow">https://github.com/Skater901/roll20-character-sheets/blob/BTATOW/BattleTech-A-Time-of-War/BattleTech-A-Time-of-War.html#L1566-L1672</a> Thanks all.
1559314686
Finderski
Pro
Sheet Author
Compendium Curator
In my experience, this is often caused by trying to migrate fields that are empty or of a different "type". &nbsp;You may want to do a typeof check and if it's empty, skip migrating it and see if that solves the problem.
That could very well explain it... I did notice it happened once when I accidentally left the XP amount blank in a skill that was being migrated. The previous skill should definitely have a skill value, and an XP value, but it may not have a Notes value. With that in mind, perhaps this is the line causing the problem? <a href="https://github.com/Skater901/roll20-character-sheets/blob/BTATOW/BattleTech-A-Time-of-War/BattleTech-A-Time-of-War.html#L1653" rel="nofollow">https://github.com/Skater901/roll20-character-sheets/blob/BTATOW/BattleTech-A-Time-of-War/BattleTech-A-Time-of-War.html#L1653</a> Everywhere else that I try to use the value of Notes I check if it's undefined first, I'm pretty sure, but here I'm not. I wouldn't think it matters if I try to put an undefined value into an object, but maybe it doesn't like that. I'll try putting a check in before assigning that value, to see if it fixes the error. Thanks for the tip. :)