duct-tape2/ai-language-partner

backend: add tests for malformed dialogue pack metadata

Open

#21 opened on Jul 8, 2026

View on GitHub
 (4 comments) (0 reactions) (1 assignee)TypeScript (2 forks)auto 404
backendclaimedgood first issuetests

Repository metrics

Stars
 (2 stars)
PR merge metrics
 (PR metrics pending)

Description

Goal

Add regression coverage proving that malformed manifest.json content never crashes dialogue-pack listing.

Scope

  • Work in apps/api/tests/test_api_contract.py.
  • Import list_dialogue_packs from app.dialogue_match.
  • Use pytest's tmp_path to create a small persona/version/manifest.json tree containing invalid JSON.
  • Call list_dialogue_packs(tmp_path) and assert that listing completes without an exception.
  • Assert that the returned pack keeps the directory-derived personaId and packVersion, while topics and levels fall back to empty lists and the three count fields fall back to 0.
  • Keep the PR focused on this regression test. Change production code only if the new test exposes a real failure.

Acceptance Criteria

  • Invalid manifest JSON does not crash pack listing.
  • Safe default metadata is asserted explicitly.
  • Existing valid dialogue-pack behavior remains covered and passing.
  • The PR body includes Closes #21 and names the checks run.

Suggested Verification

cd apps/api
.venv/bin/python -m pytest tests/test_api_contract.py -k dialogue_pack
cd ../..
python3 scripts/check_public_tree.py

Codespaces is available if you do not have the backend environment locally: https://duct-tape2.github.io/ai-language-partner/community/CODESPACES_FIRST_PR.html

Contributor guide