Skip to content

fix: return friendly errors for malformed info.toml files #44

Description

@abhiksark

Motivation

A malformed or unsafe workspace manifest should explain the problem without exposing a Python traceback. Learners and contributors need an actionable path, and paths must remain safely scoped to the workspace.

Current evidence

  • pythonlings/core/manifest.py calls tomllib.load() without translating TOML decode errors.
  • Required exercise fields are indexed directly, so missing or wrong-shaped fields can surface raw KeyError/type errors.
  • The current path check requires an exercises/ prefix but does not explicitly reject absolute paths or traversal components.

Exact scope

Convert malformed TOML, missing/wrong field shapes, and unsafe absolute or traversal paths into contextual ManifestError messages. CLI callers must print a friendly pythonlings: … error and exit 2 without a traceback.

Acceptance checklist

  • Invalid TOML produces a ManifestError that identifies info.toml and the parsing problem.
  • Missing or wrongly typed required fields produce contextual ManifestError messages, not raw exceptions.
  • Absolute paths and paths containing traversal components are rejected before filesystem access.
  • Valid relative paths under exercises/ retain existing behavior.
  • CLI integration tests confirm exit code 2 and absence of traceback text for representative failures.

Explicit exclusions

Do not change the manifest schema, accept paths outside exercises/, silently repair invalid manifests, or broaden the issue into curriculum migration.

Likely files

  • pythonlings/core/manifest.py
  • tests/unit/test_manifest.py
  • tests/integration/test_cli_verify.py and related CLI tests

Verification

python -m pytest tests/unit/test_manifest.py tests/integration/test_cli_verify.py -q
python -m pytest -q

Manually run a CLI command against malformed, missing-field, absolute-path, and traversal-path fixture manifests; each must exit 2 with a friendly message.

Sprint coordination

See the sprint Discussion. This issue is unassigned and is not a reservation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreCore workspace, manifest, state, and runner behaviorbugSomething isn't workingdev sprintPythonlings Community Dev Sprint August 2026good first issueGood for newcomerssize: MMedium, self-contained contribution

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions