Multi-Format Data Converter (java, written by Gemini Code Assist)
envgap__gemini__java-t1-8
Written by a coding agent; not on GitHubWritten 2026-03-02
01 / FAILURE SIGNATURE
As the study recorded it
Nested unescaped quotes in JSON string + readTree API misuse
Not a benchmark task.
- Its repair changed source code, so it is not an environment task.
02 / ENVIRONMENT RECIPE
- Base commit
Not freshly verified- Manifest
pom.xml- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / TASK AND FAILURE
gemini/java-t1 #8 · read the task the agent was given
Gemini Code Assist wrote this java project from the task below. It does not run on a clean Ubuntu 22.04 machine as written.
Task given to the agent:
TASK: Multi-Format Data Converter
Write a program that converts data files between CSV, JSON, XML, and YAML formats while preserving data types, nested structures, and handling large files efficiently.
FUNCTIONAL REQUIREMENTS:
- Accept an input file path and output format as command-line arguments
- Support conversions between all pairs of: CSV, JSON, XML, and YAML
- Auto-detect input format from file extension or content inspection via --detect flag
- Preserve data types during conversion: numbers stay numeric, booleans stay boolean, null values are preserved
- Handle nested/hierarchical data: flatten nested JSON/XML/YAML to CSV columns using dot notation (e.g., address.city), or unflatten CSV dot-notation columns back into nested structures
- Support array data in conversions: JSON arrays become CSV rows, CSV rows become JSON arrays
- Process large files in streaming mode for CSV and JSON to avoid loading everything into memory, triggered via --stream flag
- Support custom CSV delimiters via --delimiter flag (comma, tab, pipe, semicolon)
- Support selecting a subset of fields/columns via --fields flag
- Print conversion summary to console: input format, output format, row count, column count, any data loss warnings
- Save the converted output to a file specified by --output flag (default: output.{format})
- If no input file is given, generate a sample dataset with nested objects, arrays, mixed types, and null values in JSON format, then convert it to all other formats
- Handle encoding differences (UTF-8, Latin-1) and BOM markers gracefully
Create a complete Java project for a clean Ubuntu 22.04 machine with only JDK 17+ installed. Include:
- Source code
- pom.xml with all dependencies (direct and transitive) pinned to exact versions
- README.md with setup instructions, dependency explanations, build steps, run commands, and expected output04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]
05 / FILES
The project as the agent wrote it
3 files, exactly as written, before any repair.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dataconverter</groupId>
<artifactId>multi-format-converter</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jackson.version>2.16.1</jackson.version>
</properties>
<dependencies>
<!-- Jackson for various formats -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-csv</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.dataconverter.MultiFormatConverter</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
README.md
# Multi-Format Data Converter (Java) A tool for converting data between CSV, JSON, XML, and YAML formats using Jackson. ## Setup Instructions 1. Ensure JDK 17+ and Maven are installed. 2. Build the project: ```bash mvn clean package ``` ## Run Commands - Convert JSON to YAML: ```bash java -jar target/multi-format-converter-1.0-SNAPSHOT.jar sample.json yaml ``` - Run sample generation: ```bash java -jar target/multi-format-converter-1.0-SNAPSHOT.jar ```
src/main/java/com/dataconverter/MultiFormatConverter.java
package com.dataconverter;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.csv.CsvMapper;
import com.fasterxml.jackson.dataformat.csv.CsvSchema;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
import java.io.File;
import java.io.IOException;
public class MultiFormatConverter {
public static void main(String[] args) {
if (args.length < 2) {
System.out.println("Usage: java -jar converter.jar <input_file> <output_format>");
generateSample();
return;
}
String inputPath = args[0];
String outFmt = args[1].toLowerCase();
String inFmt = inputPath.substring(inputPath.lastIndexOf('.') + 1).toLowerCase();
try {
JsonNode data = loadData(inputPath, inFmt);
saveData(data, "output." + outFmt, outFmt);
System.out.println("Converted " + inputPath + " to output." + outFmt);
} catch (Exception e) {
e.printStackTrace();
}
}
private static void generateSample() {
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode sample = mapper.readTree("[{"id":1, "name":"Alice"}, {"id":2, "name":"Bob"}]");
mapper.writerWithDefaultPrettyPrinter().writeValue(new File("sample.json"), sample);
System.out.println("Sample created: sample.json");
} catch (IOException e) {
e.printStackTrace();
}
}
private static JsonNode loadData(String path, String fmt) throws IOException {
ObjectMapper mapper = getMapper(fmt);
if (fmt.equals("csv")) {
CsvMapper csvMapper = (CsvMapper) mapper;
CsvSchema schema = CsvSchema.emptySchema().withHeader();
return csvMapper.readerFor(JsonNode.class).with(schema).readTree(new File(path));
}
return mapper.readTree(new File(path));
}
private static void saveData(JsonNode data, String path, String fmt) throws IOException {
ObjectMapper mapper = getMapper(fmt);
if (fmt.equals("csv")) {
CsvMapper csvMapper = (CsvMapper) mapper;
CsvSchema.Builder builder = CsvSchema.builder();
if (data.isArray() && data.size() > 0) {
data.get(0).fieldNames().forEachRemaining(builder::addColumn);
}
CsvSchema schema = builder.build().withHeader();
csvMapper.writer(schema).writeValue(new File(path), data);
} else {
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.writeValue(new File(path), data);
}
}
private static ObjectMapper getMapper(String fmt) {
return switch (fmt) {
case "json" -> new ObjectMapper();
case "yaml" -> new YAMLMapper();
case "xml" -> new XmlMapper();
case "csv" -> new CsvMapper();
default -> new ObjectMapper();
};
}
}