[SPIGOT-3151] Spigot is not correctly parsing YAML files. Created: 25/Mar/17  Updated: 25/Mar/17  Resolved: 25/Mar/17

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Luke Anderson Assignee: Unassigned
Resolution: Invalid Votes: 0
Labels: Configuration, config, yaml, yml


 Description   

When loading the following configuration file:

https://gist.github.com/stuntguy3000/27576af93e868a33baed108bf3bf2fdc

Spigot throws this error - despite the YAML being valid. (www.yamllint.com, www.yaml-online-parser.appspot.com

java.lang.IllegalArgumentException: Cannot set to an empty path
at org.apache.commons.lang.Validate.notEmpty(Validate.java:321) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.configuration.MemorySection.set(MemorySection.java:167) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.configuration.MemorySection.set(MemorySection.java:201) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.configuration.file.YamlConfiguration.convertMapsToSections(YamlConfiguration.java:79) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.configuration.file.YamlConfiguration.convertMapsToSections(YamlConfiguration.java:77) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.configuration.file.YamlConfiguration.convertMapsToSections(YamlConfiguration.java:77) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.configuration.file.YamlConfiguration.convertMapsToSections(YamlConfiguration.java:77) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:67) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:184) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:130) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(YamlConfiguration.java:179) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at me.stuntguy3000.[redacted].handler.ModuleHandler.getModuleConfig(ModuleHandler.java:89) ~[?:?]
at me.stuntguy3000.[redacted].handler.ModuleHandler.load(ModuleHandler.java:37) ~[?:?]
at me.stuntguy3000.[redacted].registerHandlers([redacted].java:28) ~[?:?]
at me.stuntguy3000.[redacted].engine.MinecraftPlugin.onEnable(MinecraftPlugin.java:42) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:271) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.craftbukkit.v1_11_R1.CraftServer.enablePlugin(CraftServer.java:376) [spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at org.bukkit.craftbukkit.v1_11_R1.CraftServer.enablePlugins(CraftServer.java:326) [spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at net.minecraft.server.v1_11_R1.MinecraftServer.t(MinecraftServer.java:419) [spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at net.minecraft.server.v1_11_R1.MinecraftServer.l(MinecraftServer.java:380) [spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at net.minecraft.server.v1_11_R1.MinecraftServer.a(MinecraftServer.java:335) [spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at net.minecraft.server.v1_11_R1.DedicatedServer.init(DedicatedServer.java:272) [spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:542) [spigot-1.11.2.jar:git-Spigot-7d78b81-27dd3ca]
at java.lang.Thread.run(Unknown Source) R[?:1.8.0_121]

 

Removing lines 7, 13, 19 and 25 allow the config to be loaded. 



 Comments   
Comment by md_5 [ 25/Mar/17 ]

This is not a valid yaml document in the way you think it is.
For obvious reasons Spigot cannot load yaml documents that look like this:

foo:
  bar.:
   baz: "daz"

Why? Because bar has a trailing . and would thus create an empty section.
Accessing it section wise would mean something like:

getConfigurationSection( "foo" ).getConfigurationSection( "bar" ).getConfigurationSection( "" )

Which makes absolutely no sense - blank section as the error says.

Now if you look at your config, you've actually created a section that looks like this:

    rewards:
      STONE: say yolo xd
      torch;1;0;&b&l&oSky&3&l&oLight;&fSkylights&5 can be redeemed|with staff to create &fwarps|and light &fnether_portals.: say xd

In other words you have a section which has a key of "torch;1;0;&b&l&oSky&3&l&oLight;&fSkylights&5 can be redeemed|with staff to create &fwarps|and light &fnether_portals." - note the trailing dot.

If you really want to allow this you can set the path separator to something other than dot, however I think your config makes no sense because why exactly would that huge monstrosity be the KEY of something. Remember keys should be short descriptors of the data, not actually the data itself which is you what appear to have there.

Comment by Luke Anderson [ 25/Mar/17 ]

I have performed a bit more testing, the issue is the period in the key name.

Comment by Luke Anderson [ 25/Mar/17 ]

https://gist.github.com/stuntguy3000/27576af93e868a33baed108bf3bf2fdc

Generated at Tue Apr 22 03:30:26 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.