Skip to content

[Bug]: SnakeYamlOps getMapEntries() returns raw strings instead of wrapped objects #153

@Splatcrafter

Description

@Splatcrafter

AI REVIEWED

Module: codec
File: codec/yaml/snakeyaml/SnakeYamlOps.java (~line 873)
Severity: High

Summary

SnakeYamlOps.getMapEntries() returns Pair.of(String, Object) with raw string keys, while all Jackson-based implementations return keys wrapped as TextNode.valueOf(key). This inconsistency causes problems during cross-format conversion — consumer code expecting wrapped objects receives raw strings.

Expected Behavior

Map entry keys should be consistently wrapped as the format's native string type, matching the pattern used by Jackson implementations.

Actual Behavior

// Jackson implementations:
Pair.of(TextNode.valueOf(entry.getKey()), entry.getValue()) // wrapped

// SnakeYamlOps:
Pair.of(entry.getKey(), entry.getValue()) // raw String

Suggested Fix

Wrap keys consistently:

Pair.of((Object) entry.getKey(), entry.getValue())

Or if SnakeYAML has a canonical string wrapper, use that. The key point is that the return type should match what createString() produces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions