decorators-squad / decorators-squad/eo-yaml

YamlMapping.toString() generates incorrect structure when printing nested fields with same keys

Open
#635 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
272
Forks
55
PR merge metrics
No merged PRs in 30d

Description

When parsing a YAML file that contains multiple nested `path` keys in different contexts, the output of `YamlMapping.toString()` incorrectly merges these fields, misrepresenting the actual structure.

✅ Input YAML
```yaml
meta:
credentials:
- storage:
path: /var/artipie/security1
type: fs
type: artipie
repo_configs: repo
storage:
path: /var/artipie/
type: fs
```

📋 Java Code
```java
import com.amihaiemil.eoyaml.Yaml;
import com.amihaiemil.eoyaml.YamlMapping;

import java.io.File;
import java.io.IOException;

public class LocalTest {
public static void main(String[] args) throws IOException {
YamlMapping yamlMapping = Yaml.createYamlInput(new File(args[0])).readYamlMapping();
System.out.println(yamlMapping);
}
}
```

🧪 Expected Output
```yaml
meta:
credentials:
- storage:
path: /var/artipie/security1
type: fs
type: artipie
repo_configs: repo
storage:
path: /var/artipie/
type: fs
```

❌ Actual Output (Incorrect)
```yaml
meta:
credentials:
-
storage:
path: /var/artipie/security1
type: fs
type: artipie
path: /var/artipie/
repo_configs: repo
storage:
path: /var/artipie/security1 # ← this is wrong
type: fs
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.