{"record":{"id":"48d6ed22b075f370","repo":"tursodatabase/turso","slug":"each-sweep-file-must-have-a-distinct-positive-connection","errorCode":null,"errorMessage":"each sweep file must have a distinct positive connection count","messagePattern":"each sweep file must have a distinct positive connection count","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"perf/fts/plot/plot-fts.py","lineNumber":57,"sourceCode":"    configuration, samples = (\n        read_sweep(args.csv_files, args.percentile) if args.sweep else read_runs(args.csv_files, args.percentile)\n    )\n    for output in args.output or [Path(\"fts.png\"), Path(\"fts.pdf\")]:\n        if args.sweep:\n            plot_sweep(configuration, samples, output, args.relative)\n        else:\n            plot(configuration, samples, output)\n        print(f\"wrote {output}\")\n\n\ndef read_sweep(paths, percentile=\"p50\"):\n    configuration = None\n    points = {}\n    for path in paths:\n        current, samples = read_runs([path], percentile)\n        connections = int(current.pop(\"connections\"))\n        if connections <= 0 or connections in points:\n            raise ValueError(\"each sweep file must have a distinct positive connection count\")\n        if configuration is None:\n            configuration = current\n        if current != configuration or (points and set(samples) != set(next(iter(points.values())))):\n            raise ValueError(\"sweep files must match benchmark, sample budget, fixture and engine/mode series\")\n        points[connections] = samples\n    if not points:\n        raise ValueError(\"no sweep results found\")\n    return configuration, dict(sorted(points.items()))\n\n\ndef read_runs(paths, percentile=\"p50\"):\n    configuration = None\n    samples = {}\n    expected_series = None\n    for path in paths:\n        current, runs = read_file(path, percentile, samples)\n        if configuration is None:\n            configuration = current","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/tursodatabase/turso/blob/8d4a589f8d13ac184700d2a8f724f27e1995be3b/perf/fts/plot/plot-fts.py#L39-L75","documentation":"read_sweep aggregates multiple FTS benchmark sweep CSV files into one plot series keyed by connection count. It raises this ValueError when a file's 'connections' value is zero/negative or duplicates a connection count already seen in another sweep file, because the plot needs one distinct x-axis point per file.","triggerScenarios":"Calling read_sweep (via main) with sweep CSVs where two files record the same 'connections' value, or a file records connections <= 0.","commonSituations":"Copying a sweep result file and forgetting to rerun with a different connection count; a buggy benchmark run writing connections=0; passing the same file twice on the command line.","solutions":["Rerun the benchmark sweep with a unique, positive connection count for each result file.","Remove duplicate sweep files that record the same connection count.","Fix the CSV generation so the 'connections' column always holds a positive integer."],"exampleFix":"# before\npython plot-fts.py results/c8.csv results/c8.csv\n# after\npython plot-fts.py results/c1.csv results/c8.csv results/c32.csv","handlingStrategy":"validation","validationCode":"import csv\nconns = [int(next(csv.DictReader(open(p))['connections'])) for p in paths]\nassert all(c > 0 for c in conns), 'all connection counts must be positive'\nassert len(set(conns)) == len(conns), 'connection counts must be distinct across sweep files'","typeGuard":null,"tryCatchPattern":"try:\n    config, points = read_sweep(paths)\nexcept ValueError as e:\n    if 'distinct positive connection count' in str(e):\n        print('Fix: rerun sweeps with unique, positive connection counts')\n    else:\n        raise","preventionTips":["Name sweep result files by connection count and verify uniqueness before plotting.","Never pass the same sweep file twice on the command line.","Add a sanity check in the benchmark harness that connections is a positive integer."],"tags":["python","benchmarking","input-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"8d4a589f8d13ac184700d2a8f724f27e1995be3b","analyzedAt":"2026-09-20T13:18:14.658Z","contentChangedAt":"2026-09-20T13:18:14.658Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}