FA-48571 / Delimited text / Open access
Unit parsing strips significant spaces from column names · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
Unit parsing strips significant spaces from column names.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: name,unit=cell[:opening],
Unsuccessful approach: The alternate implementation still violates the same declared invariant: unit parsing strips significant spaces from column names.
Case contract
Parse comma header cells with optional terminal [unit]. Return [name,unit-or-null]. Only one terminal bracket pair is allowed; name and unit must be nonempty. Bare header names are preserved including spaces; bracket text is not normalized. Duplicate full name/unit pairs reject, but one name with different units is allowed.
Why this case matters
Delimited interchange needs explicit framing, schema and field semantics at ingestion and emission boundaries.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
if value == '@END': return 3 + 4*N
if isinstance(value, str): return value.replace('@', 'cell' * N)
if isinstance(value, list): return [_vary(x) for x in value]
if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
return value
N = 1
observations = []
def solve(data):
out=[]
for cell in data.split(','):
if '[' in cell:
opening=cell.find('[')
if not cell.endswith(']') or cell.count('[')!=1 or cell.count(']')!=1: return None
name,unit=cell[:opening].strip(),cell[opening+1:-1]
if not name or not unit: return None
else:
if not cell or ']' in cell: return None
name,unit=cell,None
pair=[name,unit]
if pair in out: return None
out.append(pair)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('units', solve(_vary('@ [kg],time[s]')), _vary([['@ ', 'kg'], ['time', 's']]))
check('bare', solve(_vary('@')), _vary([['@', None]]))
check('two units', solve(_vary('mass[kg],mass[g]')), _vary([['mass', 'kg'], ['mass', 'g']]))
check('duplicate', solve(_vary('a[x],a[x]')), _vary(None))
check('empty unit', solve(_vary('a[]')), _vary(None))
check('empty name', solve(_vary('[kg]')), _vary(None))
check('suffix', solve(_vary('a[x]tail')), _vary(None))
check('nested', solve(_vary('a[[x]]')), _vary(None))
check('bare space', solve(_vary(' name ')), _vary([[' name ', None]]))
check('unit exact spelling', solve(_vary('a[ Pa ],b[Pa]')), _vary([['a', ' Pa '], ['b', 'Pa']]))
check('shared unit', solve(_vary('a[x],b[x]')), _vary([['a', 'x'], ['b', 'x']]))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| units | [['cell', 'kg'], ['time', 's']] | [['cell ', 'kg'], ['time', 's']] | Failed |
| bare | [['cell', None]] | [['cell', None]] | Passed |
| two units | [['mass', 'kg'], ['mass', 'g']] | [['mass', 'kg'], ['mass', 'g']] | Passed |
| duplicate | None | None | Passed |
| empty unit | None | None | Passed |
| empty name | None | None | Passed |
| suffix | None | None | Passed |
| nested | None | None | Passed |
| bare space | [[' name ', None]] | [[' name ', None]] | Passed |
| unit exact spelling | [['a', ' Pa '], ['b', 'Pa']] | [['a', ' Pa '], ['b', 'Pa']] | Passed |
| shared unit | [['a', 'x'], ['b', 'x']] | [['a', 'x'], ['b', 'x']] | Passed |
SHA-256 / 4c6c0929d006d48c3b29573a72552a75e58a94ea48cde369aaf394b1f8097948
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
if value == '@END': return 3 + 4*N
if isinstance(value, str): return value.replace('@', 'cell' * N)
if isinstance(value, list): return [_vary(x) for x in value]
if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
return value
N = 1
observations = []
def solve(data):
out=[]
for cell in data.split(','):
if '[' in cell:
opening=cell.find('[')
if not cell.endswith(']') or cell.count('[')!=1 or cell.count(']')!=1: return None
name,unit=cell[:opening].rstrip(),cell[opening+1:-1]
if not name or not unit: return None
else:
if not cell or ']' in cell: return None
name,unit=cell,None
pair=[name,unit]
if pair in out: return None
out.append(pair)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('units', solve(_vary('@ [kg],time[s]')), _vary([['@ ', 'kg'], ['time', 's']]))
check('bare', solve(_vary('@')), _vary([['@', None]]))
check('two units', solve(_vary('mass[kg],mass[g]')), _vary([['mass', 'kg'], ['mass', 'g']]))
check('duplicate', solve(_vary('a[x],a[x]')), _vary(None))
check('empty unit', solve(_vary('a[]')), _vary(None))
check('empty name', solve(_vary('[kg]')), _vary(None))
check('suffix', solve(_vary('a[x]tail')), _vary(None))
check('nested', solve(_vary('a[[x]]')), _vary(None))
check('bare space', solve(_vary(' name ')), _vary([[' name ', None]]))
check('unit exact spelling', solve(_vary('a[ Pa ],b[Pa]')), _vary([['a', ' Pa '], ['b', 'Pa']]))
check('shared unit', solve(_vary('a[x],b[x]')), _vary([['a', 'x'], ['b', 'x']]))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| units | [['cell', 'kg'], ['time', 's']] | [['cell ', 'kg'], ['time', 's']] | Failed |
| bare | [['cell', None]] | [['cell', None]] | Passed |
| two units | [['mass', 'kg'], ['mass', 'g']] | [['mass', 'kg'], ['mass', 'g']] | Passed |
| duplicate | None | None | Passed |
| empty unit | None | None | Passed |
| empty name | None | None | Passed |
| suffix | None | None | Passed |
| nested | None | None | Passed |
| bare space | [[' name ', None]] | [[' name ', None]] | Passed |
| unit exact spelling | [['a', ' Pa '], ['b', 'Pa']] | [['a', ' Pa '], ['b', 'Pa']] | Passed |
| shared unit | [['a', 'x'], ['b', 'x']] | [['a', 'x'], ['b', 'x']] | Passed |
SHA-256 / ba89932c45b7f019e040de01a557737036fe7f7b28954a27ce1e60c64463ac4d
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
if value == '@END': return 3 + 4*N
if isinstance(value, str): return value.replace('@', 'cell' * N)
if isinstance(value, list): return [_vary(x) for x in value]
if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
return value
N = 1
observations = []
def solve(data):
out=[]
for cell in data.split(','):
if '[' in cell:
opening=cell.find('[')
if not cell.endswith(']') or cell.count('[')!=1 or cell.count(']')!=1: return None
name,unit=cell[:opening],cell[opening+1:-1]
if not name or not unit: return None
else:
if not cell or ']' in cell: return None
name,unit=cell,None
pair=[name,unit]
if pair in out: return None
out.append(pair)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('units', solve(_vary('@ [kg],time[s]')), _vary([['@ ', 'kg'], ['time', 's']]))
check('bare', solve(_vary('@')), _vary([['@', None]]))
check('two units', solve(_vary('mass[kg],mass[g]')), _vary([['mass', 'kg'], ['mass', 'g']]))
check('duplicate', solve(_vary('a[x],a[x]')), _vary(None))
check('empty unit', solve(_vary('a[]')), _vary(None))
check('empty name', solve(_vary('[kg]')), _vary(None))
check('suffix', solve(_vary('a[x]tail')), _vary(None))
check('nested', solve(_vary('a[[x]]')), _vary(None))
check('bare space', solve(_vary(' name ')), _vary([[' name ', None]]))
check('unit exact spelling', solve(_vary('a[ Pa ],b[Pa]')), _vary([['a', ' Pa '], ['b', 'Pa']]))
check('shared unit', solve(_vary('a[x],b[x]')), _vary([['a', 'x'], ['b', 'x']]))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| units | [['cell ', 'kg'], ['time', 's']] | [['cell ', 'kg'], ['time', 's']] | Passed |
| bare | [['cell', None]] | [['cell', None]] | Passed |
| two units | [['mass', 'kg'], ['mass', 'g']] | [['mass', 'kg'], ['mass', 'g']] | Passed |
| duplicate | None | None | Passed |
| empty unit | None | None | Passed |
| empty name | None | None | Passed |
| suffix | None | None | Passed |
| nested | None | None | Passed |
| bare space | [[' name ', None]] | [[' name ', None]] | Passed |
| unit exact spelling | [['a', ' Pa '], ['b', 'Pa']] | [['a', ' Pa '], ['b', 'Pa']] | Passed |
| shared unit | [['a', 'x'], ['b', 'x']] | [['a', 'x'], ['b', 'x']] | Passed |
SHA-256 / 786974f621723854f9ce4e3b3e0e2114cb0c656819f95836b3b08a9f68113f80
Verification & scope
Deterministic bounded in-memory model. No claim of complete CSV or external format conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:44:51.969356+00:00.
Case digest / bb376042f4559e359db031a53f202eed9e4c5ac38886d890e4780588750b100c