data infer-schema / infer_data_schema fails on top-level JSON arrays (the documented example).
Environment
fairspec 0.1.4 (installed from PyPI)
- Python 3.12.3, Linux
- Reproduced in a clean virtualenv against the published wheel.
Repro
cat > users.json <<'JSON'
[
{"id": 1, "name": "Alice", "email": "alice@example.com"},
{"id": 2, "name": "Bob", "email": "bob@example.com"}
]
JSON
fairspec data infer-schema users.json --json
Actual
{ "error": "Invalid descriptor: [\n {\"id\": 1, ...}\n]\n" }
With --debug the traceback ends in fairspec_metadata/actions/descriptor/parse.py:
def parse_descriptor(text: str) -> Descriptor:
value = json.loads(text)
if not isinstance(value, dict):
raise Error(f"Invalid descriptor: {text}") # <-- top-level arrays rejected
A single top-level object ({...}) works fine.
Why it's a bug: docs/terminal/data.md documents exactly this case — fairspec data infer-schema users.json where users.json is a top-level array — and shows the expected output as {"type": "array", "items": {...}}. The data-schema path goes through parse_descriptor (descriptor parsing), which is too strict for arbitrary JSON data.
Expected: infer a Data Schema from any valid JSON value, including a top-level array.
data infer-schema/infer_data_schemafails on top-level JSON arrays (the documented example).Environment
fairspec0.1.4 (installed from PyPI)Repro
Actual
{ "error": "Invalid descriptor: [\n {\"id\": 1, ...}\n]\n" }With
--debugthe traceback ends infairspec_metadata/actions/descriptor/parse.py:A single top-level object (
{...}) works fine.Why it's a bug:
docs/terminal/data.mddocuments exactly this case —fairspec data infer-schema users.jsonwhereusers.jsonis a top-level array — and shows the expected output as{"type": "array", "items": {...}}. The data-schema path goes throughparse_descriptor(descriptor parsing), which is too strict for arbitrary JSON data.Expected: infer a Data Schema from any valid JSON value, including a top-level array.