Skip to content

ContentFormatterTests failed on Windows #595

Closed
@alexcheng1982

Description

@alexcheng1982

Bug description
ContentFormatterTests failed on Windows. This is a Windows specific issue.

org.opentest4j.AssertionFailedError: 
expected: 
  "llmKey2: value4
embedKey1: value1
embedKey2: value2
embedKey3: value3

The World is Big and Salvation Lurks Around the Corner"
 but was: 
  "llmKey2: value4
  embedKey1: value1
  embedKey2: value2
  embedKey3: value3

The World is Big and Salvation Lurks Around the Corner"

Environment
Spring AI 0.8.1
Java 17
Windows

Steps to reproduce
Just mvn test to run the tests

Expected behavior
ContentFormatterTests should pass

Minimal Complete Reproducible example
Just the main repo

I did some investigation and found out the issue was with the DEFAULT_METADATA_SEPARATOR. On Windows, the default metadata separator System.lineSeparator() is \r\n, not \n.

private static final String DEFAULT_METADATA_SEPARATOR = System.lineSeparator();

The test uses a text block as the expected result, which always uses \n. So on Windows the assertion failed, as the formatted content has an extra \r in it.

The customTextFormatter test can be fixed by overriding the default metadata separator using withMetadataSeparator("\n"). However, the defaultConfigTextFormatter test cannot be fixed in this way, as there is no way to configure the default DefaultContentFormatter.

Another option is to set the DEFAULT_METADATA_SEPARATOR to \n. Not sure about the impact of changing the default metadata separator.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions