← All tasks
javascriptgemini/javascript-t1 #8Not a task: already works

Multi-Format Data Converter (javascript, written by Gemini Code Assist)

envgap__gemini__javascript-t1-8

Written by a coding agent; not on GitHubWritten 2026-03-02

01 / FAILURE SIGNATURE

As the study recorded it

No identifying execution failure has been captured.
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
Not freshly verified
Manifest
package.json
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / TASK AND FAILURE

gemini/javascript-t1 #8 · read the task the agent was given
Gemini Code Assist wrote this javascript project from the task below. It installed and ran 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 JavaScript project for a clean Ubuntu 22.04 machine with only Node.js 20+ (LTS) installed. Include:
- Source code
- package.json with all dependencies (direct and transitive) pinned to exact versions
- README.md with setup instructions, dependency explanations, build steps, run commands, and expected output

04 / 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.

data_converter.js
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
const { XMLParser, XMLBuilder } = require('fast-xml-parser');
const { parse } = require('csv-parse/sync');
const { stringify } = require('csv-stringify/sync');
const _ = require('lodash');
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');

const argv = yargs(hideBin(process.argv))
    .option('output-format', { choices: ['csv', 'json', 'xml', 'yaml'] })
    .argv;

const xmlParser = new XMLParser({ ignoreAttributes: false });
const xmlBuilder = new XMLBuilder({ ignoreAttributes: false, format: true });

function generateSample() {
    const data = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
    fs.writeFileSync('sample.json', JSON.stringify(data, null, 4));
}

function flatten(obj, prefix = '', res = {}) {
    for (let key in obj) {
        let p = prefix ? prefix + '.' + key : key;
        if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {
            flatten(obj[key], p, res);
        } else {
            res[p] = obj[key];
        }
    }
    return res;
}

const inputPath = argv._[0] || 'sample.json';
if (!fs.existsSync(inputPath)) generateSample();

const inFmt = path.extname(inputPath).slice(1);
const outFmt = argv.outputFormat || 'csv';
const content = fs.readFileSync(inputPath, 'utf8');

let data;
if (inFmt === 'json') data = JSON.parse(content);
else if (inFmt === 'yaml') data = yaml.load(content);
else if (inFmt === 'xml') data = xmlParser.parse(content).root.items;
else if (inFmt === 'csv') data = parse(content, { columns: true });

let output;
if (outFmt === 'json') output = JSON.stringify(data, null, 4);
else if (outFmt === 'yaml') output = yaml.dump(data);
else if (outFmt === 'xml') output = xmlBuilder.build({ root: { items: data } });
else if (outFmt === 'csv') {
    const flatData = Array.isArray(data) ? data.map(item => flatten(item)) : [flatten(data)];
    output = stringify(flatData, { header: true });
}

const outPath = `output.${outFmt}`;
fs.writeFileSync(outPath, output);
console.log(`Converted ${inputPath} to ${outPath}`);
package.json
{
  "name": "multi-format-converter",
  "version": "1.0.0",
  "description": "Convert between CSV, JSON, XML, and YAML",
  "main": "data_converter.js",
  "engines": {
    "node": ">=20.0.0"
  },
  "dependencies": {
    "fast-xml-parser": "4.3.4",
    "js-yaml": "4.1.0",
    "csv-parse": "5.5.3",
    "csv-stringify": "6.4.5",
    "lodash": "4.17.21",
    "yargs": "17.7.2"
  },
  "scripts": {
    "start": "node data_converter.js"
  }
}
README.md
# Multi-Format Data Converter (JavaScript)

A tool for converting data between CSV, JSON, XML, and YAML formats.

## Setup Instructions

1. Ensure Node.js 20+ (LTS) is installed.
2. Install dependencies:
   ```bash
   npm install
   ```

## Run Commands

- Convert JSON to YAML:
  ```bash
  node data_converter.js sample.json --output-format yaml
  ```
- Run with generated sample data:
  ```bash
  node data_converter.js
  ```