question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

& char cannot read in folded scalar contents.

See original GitHub issue

Reading a yml file that contains folded scalar throws java.lang.StringIndexOutOfBoundsException: String index out of range: -1 the file;

"help-messages": >
  &a====== %prefix% Player Commands &a======
  &7/rank &r> &eShows help message.
  &7/rank help &r> &eShows help message.
  &7/rank menu &r> &eOpens your profile menu.
  &7/rank check &r> &eCheck and promote your rank.
  &7/rank list &r> &eShows all ranks.
  &a====== %prefix% Admin Commands &a======
  &7/rank reload &r> &eReloads the plugin.
  &7/rank version &r> &eChecks for update.
  &7/rank promote <player> &r> &eInstantly promote the player.
  &7/rank set <player> <rank> &r> &eChange the player rank.
  &7/rank menu <target> &r> &eShows profile menu of the target.

the method that I use: Yaml.createYamlInput(contents).readYamlMapping() and full error message

java.lang.StringIndexOutOfBoundsException: String index out of range: -1

	at java.base/java.lang.String.substring(String.java:1837)
	at com.amihaiemil.eoyaml.RtYamlLine.requireNestedIndentation(RtYamlLine.java:152)
	at com.amihaiemil.eoyaml.WellIndented.iterator(WellIndented.java:125)
	at com.amihaiemil.eoyaml.SameIndentationLevel.iterator(SameIndentationLevel.java:74)
	at com.amihaiemil.eoyaml.ReadYamlMapping.lambda$comment$6(ReadYamlMapping.java:199)
	at com.amihaiemil.eoyaml.Skip.iterator(Skip.java:74)
	at com.amihaiemil.eoyaml.Backwards.iterator(Backwards.java:69)
	at com.amihaiemil.eoyaml.FirstCommentFound.iterator(FirstCommentFound.java:83)
	at com.amihaiemil.eoyaml.Backwards.iterator(Backwards.java:69)
	at com.amihaiemil.eoyaml.ReadComment.value(ReadComment.java:66)
	at com.amihaiemil.eoyaml.RtYamlPrinter.printPossibleComment(RtYamlPrinter.java:298)
	at com.amihaiemil.eoyaml.RtYamlPrinter.print(RtYamlPrinter.java:69)
	at com.amihaiemil.eoyaml.BaseYamlNode.toString(BaseYamlNode.java:104)
	at java.base/java.lang.String.valueOf(String.java:2951)
	at java.base/java.lang.StringBuilder.append(StringBuilder.java:168)
	at io.github.portlek.configs.files.yaml.Helper.loadFromString(Helper.java:52)
	at io.github.portlek.configs.files.yaml.YamlConfiguration.loadFromString(YamlConfiguration.java:62)
	at io.github.portlek.configs.configuration.FileConfiguration.load(FileConfiguration.java:77)
	at io.github.portlek.configs.configuration.FileConfiguration.load(FileConfiguration.java:59)
	at io.github.portlek.configs.files.yaml.YamlConfiguration.loadConfiguration(YamlConfiguration.java:41)
	at io.github.portlek.configs.files.FileType.load(FileType.java:53)
	at io.github.portlek.configs.processors.ConfigProceed.load(ConfigProceed.java:77)
	at java.base/java.util.Optional.ifPresent(Optional.java:183)
	at io.github.portlek.configs.processors.LinkedConfigProceed.load(LinkedConfigProceed.java:50)
	at io.github.portlek.configs.structure.linked.LnkdManaged.load(LnkdManaged.java:52)
	at io.github.portlek.configs.structure.RunnerTest.before(RunnerTest.java:38)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptLifecycleMethod(TimeoutExtension.java:126)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptBeforeAllMethod(TimeoutExtension.java:68)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllMethods$8(ClassBasedTestDescriptor.java:375)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllMethods(ClassBasedTestDescriptor.java:373)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:193)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:78)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:132)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)
	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)
	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
amihaiemilcommented, Jun 30, 2020

@portlek 5.1.3 is out, with the workaround. I will fix this Issue, probably in the weekend, with the correct, escaping solution.

1reaction
amihaiemilcommented, Jun 30, 2020

@portlek I’m pretty sure the problem is here. Everything after & gets cut off – the intent was to eliminate aliases and achors (which are not yet supported).

I’ll fix it asap.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Convert YAML multi-line values to folded block scalar style?
Using ruamel.yaml I tried to get a YAML in a certain style, more specifically one where single-line strings start at same line as...
Read more >
YAML Multiline Strings
(Scalars are what YAML calls basic values like numbers or strings, ... (To get a newline using the folded style, leave a blank...
Read more >
YAML Superpowers, part 2: Multiline Strings
Simple strings (“Flow” scalars). Let's start easy with single-line strings. It's already worth noting that, in YAML: When using double quotes "" ...
Read more >
YAML Ain't Markup Language (YAML™) revision 1.2.2
Scalar content can be written in block notation, using a literal style (indicated by “ | ”) where all line breaks are significant....
Read more >
Tips, Tricks, Troubleshooting - yq - GitBook
A reasonable way of validation a yaml file is to ensure the top level is a map or array (although it is valid...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found