ls: ensure_compliant_schema should validate, not trust, and return a more helpful error message
- Dominant language
- Python
- Stars
- 12
- Forks
- 6
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 2
Description
When `con-duct ls` reads an `info.json` that's missing a required field, the failure is opaque. This doesn't happen in the wild AFAIK, but we shouldn't rely on the handling of "whenever any field is used".
### /home/austin/devel/duct/.worktrees/add-uname-to-info-json/info.json
```
{
"schema_version": "0.2.2"
}
```
```
con-duct ls info.json
[WARNING] con_duct.ls: Failed to load file <_io.TextIOWrapper name='info.json' mode='r' encoding='UTF-8'>: 'system'
```
Two things to improve (both in `src/con_duct/ls.py`):
1. **Message quality.** Should return the path not the `io.TextIOWrapper …>` noise
2. Should surface missing keys cleanly, ie `Failed to load path/to/info.json: missing required field 'system'`.
3. **Real validation.** `ensure_compliant_schema` only trusts the claimed `schema_version` and runs migrations; it never verifies the record actually conforms. It should validate required fields so incomplete records fail the same clean way regardless of claimed version.
Context: split out of the review discussion on #425.
Contributor guide
Research direction
Start in src/con_duct/ls.py at ensure_compliant_schema and the error handling used by con-duct ls. Reproduce the shown incomplete info.json, then trace how its path and missing fields are reported. Done means errors name the file path, identify missing required fields cleanly, and validate incomplete records regardless of their claimed schema_version.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100