alibaba/spring-ai-alibaba · error · java.lang.IllegalStateException
parse default-default-application.yml failed
Error message
parse default-default-application.yml failed
What it means
After locating templates/default-application.yml, customize() parses it with SnakeYAML (new Yaml().load(in)). Any parse error — malformed YAML, tabs, invalid structure — is wrapped in IllegalStateException('parse default-default-application.yml failed', ex). This signals a corrupted or hand-edited default template that the generator cannot interpret.
Source
Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/generator/service/generator/GraphAppPropertiesCustomizer.java:44
public class GraphAppPropertiesCustomizer implements ApplicationPropertiesCustomizer {
public GraphAppPropertiesCustomizer() {
}
@Override
public void customize(ApplicationProperties properties) {
try (InputStream in = getClass().getClassLoader().getResourceAsStream("templates/default-application.yml")) {
if (in == null) {
throw new IllegalStateException("not found default-default-application.yml");
}
Yaml yaml = new Yaml();
Object loaded = yaml.load(in);
if (loaded instanceof Map<?, ?>) {
flattenAndAdd(properties, "", (Map<String, Object>) loaded);
}
}
catch (Exception ex) {
throw new IllegalStateException("parse default-default-application.yml failed", ex);
}
}
@SuppressWarnings("unchecked")
private void flattenAndAdd(ApplicationProperties props, String prefix, Map<String, Object> map) {
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = prefix.isEmpty() ? entry.getKey() : prefix + "." + entry.getKey();
Object value = entry.getValue();
if (value instanceof Map) {
flattenAndAdd(props, key, (Map<String, Object>) value);
}
else if (value instanceof List) {
props.add(key, ((List<?>) value).toString());
}
else if (value instanceof Boolean) {
props.add(key, (Boolean) value);
}
else if (value instanceof Number) {View on GitHub (pinned to f82da0b50f)
Solutions
- Validate templates/default-application.yml with a YAML linter or a quick SnakeYAML/J shell parse; fix the reported line from the cause exception
- Replace tabs with spaces and fix indentation in the template
- Check whether Maven resource filtering is mangling ${...} placeholders in the YAML — escape them or disable filtering for templates/
- Restore the original template from the upstream spring-ai-alibaba repository
Example fix
// before (invalid YAML) application: name: demo // after application: name: demo
Defensive patterns
Strategy: try-catch
Validate before calling
try (InputStream in = getClass().getClassLoader().getResourceAsStream("templates/default-application.yml")) {
new org.yaml.snakeyaml.Yaml().load(in); // throws if invalid
} Try / catch
try {
customizer.customize(properties);
} catch (IllegalStateException e) {
log.error("default-application.yml is invalid YAML: {}", e.getCause(), e);
} Prevention
- Lint YAML templates in CI (make yaml-lint)
- Use spaces, never tabs, in templates
- Escape Maven ${...} placeholders or disable filtering for templates/
- Validate the file after every manual edit
When it happens
Trigger: customize() is invoked and the bundled templates/default-application.yml contains syntactically invalid YAML (bad indentation, tabs, unescaped characters) or a top-level non-map structure causing a cast/parse failure inside the try block.
Common situations: Editing the template file by hand and introducing YAML syntax errors, using tabs instead of spaces, resource filtering placeholders breaking YAML syntax, or a broken merge/rebase of the template.
Related errors
- not found default-default-application.yml
- BuildToolSchemaError
- Type "token" is not allowed.
- Invalid memory parameter
- Invalid iterations parameter
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/b20b295d4cd135ca.
Report an issue: GitHub.