Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Island YAML corrupted after they ban another player from island #486

Closed
mattc4t opened this issue Jan 24, 2019 · 16 comments
Closed

Island YAML corrupted after they ban another player from island #486

mattc4t opened this issue Jan 24, 2019 · 16 comments
Assignees
Milestone

Comments

@mattc4t
Copy link

mattc4t commented Jan 24, 2019

Description
The island YAML file of a player becomes corrupted after they ban another player from their island. The YAML file will not parse on server startup
After startup, the player whose island file is corrupted, is given a new island, instead of their current one.

Steps to reproduce the behavior:

  1. Ban a player from your island: /island ban username
  2. Stop the server
  3. Start the server
  4. Startup log shows error:
    [21:31:45] [Server thread/ERROR]: [BentoBox] Could not load yml file from database database\Island 09831dd8-b7b4-420e-a643-1cf3b5db4de5.yml could not determine a constructor for the tag tag:yaml.org,2002:java.util.UUID
    in 'string', line 83, column 13:
    player: !!java.util.UUID '51233357-dc2b- ...

Impact:
The player whose island file is corrupt will be forced to start a new island.
The server admin must then find where the player's island was, (using hawkeye or coreprotect), go there, then register the player for the island once again

Expected behavior
Ban should not corrupt data files

Screenshots
[22:02:19 ERROR]: [BentoBox] Could not load yml file from database database\Island 66f769a9-5516-44ef-a092-48d69246aa69.yml could not determine a constructor for the tag tag:yaml.org,2002:java.util.UUID
in 'string', line 83, column 13:
player: !!java.util.UUID '51233357-dc2b- ...
^

Server Information:
CraftBukkit version git-Spigot-f56e2e7-7fc66b2 (MC: 1.13.2) (Implementing API version 1.13.2-R0.1-SNAPSHOT)

[Please complete the following information:]

  • Database being used: YAML

  • OS: Windows 10

  • Java Version: 1.8.0_151

  • BentoBox version: 1.1

  • Addons installed?
    [21:44:10 INFO]: Bentobox version: 1.1
    [21:44:10 INFO]: Loaded Game Worlds:
    [21:44:10 INFO]: SkyGrid-world (SkyGrid)
    [21:44:10 INFO]: BSkyBlock_world (BSkyBlock)
    [21:44:10 INFO]: Loaded Add-Ons
    [21:44:10 INFO]: BSkyBlock 1.0
    [21:44:10 INFO]: SkyGrid 0.0.1-SNAPSHOT
    [21:44:10 INFO]: Biomes 0.3.0-SNAPSHOT
    [21:44:10 INFO]: Challenges 0.3.1-SNAPSHOT
    [21:44:10 INFO]: Level 0.2.0
    [21:44:10 INFO]: WelcomeWarps 0.1.0-SNAPSHOT

  • Other plugins? [Do '/plugins' and copy/paste from the console]
    [21:44:46 INFO]: Plugins (66): PlayerUUID, Admin-Chat-Channel, ColoredSigns, McWiki, ColorCodeTeacher, PlaceholderAPI, PlugMan, LeadTheWay, AntiWorldFly, TicketMaster, BanManager, Hordes, ColoredChat, CheckNameHistory, AdminNotes, TreeGravity, CoreProtect, LuckPerms, WorldEdit, FirstJoinPlus, OreAnnouncer, ChatControl, WorldBorder, ProtocolLib, Stables, FastAsyncWorldEdit, iDisguise, DIYspy, SurvivalFly, Vault, MobHeads, BookManager, PerWorldInventory, HolographicDisplays, LWC, WorldGuard, MaintenanceSpigot, MyCommand, UndineMailer, HawkEye, InfernalMobs, MyWarp, Essentials, BookShelf, Jobs, ExtraContexts, TNTRun, SafeTrade, Citizens, VanishNoPacket, BentoBox, EssentialsChat, CustomOreGen, TouchscreenHolograms, PickupArrows, QuickShop, CommandNPC, Multiverse-Core, Shopkeepers, Multiverse-Portals, GriefPrevention, Holograms, ExtraHardMode, Multiverse-NetherPortals, MonsterApocalypse, Paintball
    66f769a9-5516-44ef-a092-48d69246aa69.zip

@Poslovitch
Copy link
Member

Duplicate of #482.

Download 1.2.0 devbuilds to get a fix for this bug.

@Poslovitch Poslovitch added Type: Bug Status: Duplicate Related to an existing issue. labels Jan 24, 2019
@mattc4t
Copy link
Author

mattc4t commented Jan 24, 2019

Thanks! Sorry, I searched for a duplicate, could not find one that stood-out to me. I'll try the devbuilds :)

@mattc4t
Copy link
Author

mattc4t commented Jan 24, 2019

Sorry to say that this is still an issue... I downloaded the latest 1.2.0 devbuild, repeated the same steps as before, and the YAML file is corrupted on startup - forcing the player to a newly-generated island.

@mattc4t
Copy link
Author

mattc4t commented Jan 24, 2019

65a594fa-47f5-422b-a2ab-7a40c8195076.zip

[22:59:28 ERROR]: [BentoBox] Could not load yml file from database database\Island 65a594fa-47f5-422b-a2ab-7a40c8195076.yml could not determine a constructor for the tag tag:yaml.org,2002:java.util.UUID
in 'string', line 21, column 13:
player: !!java.util.UUID '51233357-dc2b- ...
^

@Poslovitch
Copy link
Member

Poslovitch commented Jan 24, 2019

Hmm, weird.

@tastybento Does the YAML " load object" tries to read non @Expose fields? Or have I just been very naive with ae24643 ?

@Poslovitch Poslovitch reopened this Jan 24, 2019
@BONNe
Copy link
Member

BONNe commented Jan 24, 2019

Why dont you store UUIDs as strings?
As you definitely are trying to read them as string objects...

@tastybento
Copy link
Member

tastybento commented Jan 24, 2019

@Poslovitch You should use @Expose, but the actual issue is that as you are defining your own LogEntryListAdapter, the default adapters (like the UUID one) will not be used so you need to serialize the UUID as well (which is easy to do).

@Poslovitch
Copy link
Member

Oh, crap!
I'll fix this ASAP.

Will this fix the read issue, or will we need to ask our users to manually remove the "bugged" lines?

@Poslovitch Poslovitch removed the Status: Duplicate Related to an existing issue. label Jan 24, 2019
@Poslovitch Poslovitch added this to the 1.2.0 milestone Jan 24, 2019
@tastybento
Copy link
Member

It won't fix it. I'm not sure if there's a programmatic way to catch those bugged lines and ignore them or not.

@Poslovitch
Copy link
Member

I'd say I could extend the scope of the "Converter API" to actually allow us to do automated database revisions between versions... But that'd make it harder to implement ^^

@tastybento
Copy link
Member

tastybento commented Jan 24, 2019

I had a look at the code and the YAML object loading is handled entirely by Bukkit and its YAML processor. It serializes unknown objects by prefixing the class name with !! and using toString() and then hopes that there is a corresponding constructor that'll take the string input and convert it back. In the case of UUID there isn't, so it throws an error. We can't tap into that.

e.g.:
!!java.util.UUID '51233357-dc2b-4ae2-9703-ba8585b21759'

The only "hack" way to avoid this would be to open the file before loading it and scan for lines with !!java.util.UUID in them and remove the whole history section.

@tastybento
Copy link
Member

By the way, assuming you store all your history as strings, in Linux/MacOS, running this command in the Island folder of the database will remove all the offending !!java.util.UUID parts and make the files readable:

sed -e "s/!!java.util.UUID //g" -i *

Another approach would be to check if an error regarding UUID is occurring (java.util.UUID) in the exception handler of YamlDatabaseConnector (line 62) and then if it is, run the file through a utility class that will remove the !!java.util.UUID text (see here for how to do that) and then try and load it again. That'll recover any mis-written files.

Poslovitch added a commit that referenced this issue Jan 26, 2019
@Poslovitch
Copy link
Member

@tastybento May I have your review on afdfc28 ? Do you think it'll avoid this bug from happening ?

@mattc4t Do you think we should provide an automated "fix" for the islands that got "corrupted" by this bug or do you think it can be easily fixed "by hand"?

@Poslovitch Poslovitch added the Status: Need answer Waiting for more information to be provided by the issue's author. label Jan 26, 2019
tastybento added a commit that referenced this issue Jan 26, 2019
#486

Includes an autofixer for corrupted files and test for the adapter.

LogEntry was changed to just store strings instead of arbitrary types.
Unless the log serializer were to store hints as to what type of data
was being stored, it is impossible to deseralize. To make it all
simpler, we just store strings. If the UUIDs need to be converted back
to players are some point, that can be done based on the type of the log
stored.
@tastybento
Copy link
Member

@Poslovitch See db932dd. I added the auto fix too.

@tastybento tastybento removed the Status: Need answer Waiting for more information to be provided by the issue's author. label Jan 26, 2019
@mattc4t
Copy link
Author

mattc4t commented Jan 27, 2019

Great! I have a relatively small server, so I can fix the config by hand relatively easily. Skyblock has been a favorite on our server for a while.

Thank you for the rewrite and providing it for 1.13.2! I also look forward to installing SkyGrid soon...

@mattc4t
Copy link
Author

mattc4t commented Jan 27, 2019

I tried the latest 1.1.1 Devbuild: Mission Accomplished!!!

  • On startup, the plugin fixed the corrupt entry
    -After banning a player, the ban entry in the island file looked fine, without a UUID prefix before the UUID.

Thank you for the timely fix 👍

@BentoBoxWorld BentoBoxWorld locked as resolved and limited conversation to collaborators Jan 27, 2019
barpec12 pushed a commit to barpec12/BentoBox that referenced this issue Jan 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants