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

Misleading error message in YamlConfigurationLoader.loadConfig(): "Invalid yaml" #334

Open
tashoyan opened this issue Feb 15, 2022 · 0 comments

Comments

@tashoyan
Copy link

If the method YamlConfigurationLoader.loadConfig() is not able to parse the YAML config file, it throws a ConfigurationException. For example:

org.apache.cassandra.exceptions.ConfigurationException: Invalid yaml: file:/Users/taataar2/workspace/ines-spark-services/ines-spark-apps/target/scala_2.12/cassandra_embedded_db/cu-cassandra-rndport.yaml
 Error: Can't construct a java object for tag:yaml.org,2002:org.apache.cassandra.config.Config; exception=java.lang.reflect.InvocationTargetException
 in 'reader', line 10, column 1:
    cluster_name: 'Test Cluster'
    ^

This error message is misleading - a user may think, that the YAML config file is malformed. In my case, the real cause was an incompatible version of Guava library in the classpath:

java.lang.NoSuchMethodError: com.google.common.collect.Sets.newConcurrentHashSet()Ljava/util/Set;

The problem is, that the ConfigurationException misses the cause:

throw new ConfigurationException("Invalid yaml: " + url + SystemUtils.LINE_SEPARATOR
   +  " Error: " + e.getMessage(), false);

Instead the constructor with the cause argument should be used. Then we could see the underlying exception, that caused the failure.

throw new ConfigurationException(msg, cause)
@tashoyan tashoyan changed the title Misleading error message in YamlConfigurationLoader.loadConfig(): Invalid yaml Misleading error message in YamlConfigurationLoader.loadConfig(): "Invalid yaml" Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant