EddieDover / fvtt-player-achievements

A FoundryVTT module for Player Achievements.
GNU General Public License v3.0
1 stars 1 forks source link

[Bug]: User Reported a Duplicate ID/Key issue when importing/exporting. #86

Open EddieDover opened 1 week ago

EddieDover commented 1 week ago

What happened?

A user said that during the import/export process, they suddenly got a duplicate key issue that caused the entire plugin to be nonfunctional.

This needs a multi-step resolution:

1) No user should ever be soft-locked from using the module because of this issue. Duplicate keys need to be gracefully handled somehow. Most likely through deletion of either the latest in the array or the oldest.

2) Investigate the export and creation to make sure we're not getting duplicate IDs somehow.

3) Possibly add more unit tests to simulate creation and id generation to assure this isn't a more common issue than expected.

Resolution: Modify import to validate IDs and not allow blank IDs. Generate a new ID if necessary.

What type of foundry hosting were you using?

No response

Relevant console log output

[Detected 1 package: fvtt-player-achievements(1.7.2)]
    onError foundry.js:654
    onError#0 libWrapper-wrapper.js:188
    render foundry.js:5795
    promise callback*render foundry.js:5793
    toggleAchievementScreen fvtt-player-achievements.js:131
    showWindow fvtt-player-achievements.js:139
Caused by: Error: Duplicate achievement ids found
[Detected 1 package: fvtt-player-achievements(1.7.2)]
    getAchivements core.js:227
    updateAchievements fvtt-player-achievements.js:127
    filterAchievements achievement-form.js:50
    getData achievement-form.js:71
    _render foundry.js:5838
    _render foundry.js:6572
    render foundry.js:5793
    toggleAchievementScreen fvtt-player-achievements.js:131
    showWindow fvtt-player-achievements.js:139
foundry.js:655:30

Contact Details

No response

EddieDover commented 1 week ago

After speaking with the user, the issue stemmed from them manually modifying the export JSON then reimporting it, to add their own achievements faster than manual entry. The cause of the bug was from blank ID fields during import.

Fix for this issue is to make sure import IDs are correct/exist, and generate uniques if they are not/do not.