Skip to content

fix(catalog): entry-detail manifest resolution, refresh count, alembic test#89

Open
pparage wants to merge 4 commits into
feature/gamenet-authoring-v1from
fix/catalog-walker-detail-and-alembic
Open

fix(catalog): entry-detail manifest resolution, refresh count, alembic test#89
pparage wants to merge 4 commits into
feature/gamenet-authoring-v1from
fix/catalog-walker-detail-and-alembic

Conversation

@pparage
Copy link
Copy Markdown
Member

@pparage pparage commented Jun 3, 2026

Three evidence-backed quick-win fixes from the open-issue triage. Each was developed test-first (TDD); full suite 389 passing.

Changes

Tests

  • New: tests/routes/test_catalog_detail_resolver.py (4), tests/routes/test_catalog_refresh_count.py (1)
  • Fixed: tests/core/test_alembic.py
  • Full suite: 389 passed

Base is feature/gamenet-authoring-v1 — the v1 catalog code these touch does not exist on dev/main.

pparage added 3 commits June 3, 2026 11:19
The /v1/catalog/entries detail endpoint only read range42.yaml, so every
container (meta.json) and Ansible-role (meta/main.yml) entry surfaced by the
browse walker 404'd on detail. Add _detail_at_path() mirroring _discover's
manifest recognition and wire get_entry to use it.
_count_entries_in_repo counted only range42.yaml + a nonexistent catalog.yaml,
so entries_indexed was always 0 for real catalogs. Delegate to _discover so the
refresh count agrees with what /v1/catalog/entries surfaces.
The migration roundtrip test invoked bare 'alembic', which resolved to a stale
~/.local copy bound to an old SQLAlchemy lacking declarative_base. Invoke via
sys.executable -m alembic so it runs against the venv.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4cdc574cf8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/routes/v1/catalog/entries.py Outdated
Comment on lines +135 to +136
doc = load_doc(manifest.read_text()) or {}
return {**entry, "document": doc}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate parsed detail documents before returning

When a meta.json or meta/main.yml is syntactically valid but its top level is not an object (for example []), the existing summary parsers still synthesize an entry, so the browse endpoint lists it. The new detail resolver then returns that list as document, but CatalogEntryDetail.document is typed as dict, causing FastAPI/Pydantic response validation to fail with a 500 instead of either skipping the entry or returning a valid detail response. This affects malformed-but-parseable manifests in the new non-range42.yaml detail path.

Useful? React with 👍 / 👎.

A syntactically valid manifest with a non-mapping top level (e.g. a JSON/YAML
list) is still listed by the browse walker, but the detail resolver passed the
raw value through as document — failing CatalogEntryDetail.document: dict
response validation with a 500. Coerce non-dict documents to {} so the entry
resolves cleanly. Addresses Codex review feedback.
@pparage
Copy link
Copy Markdown
Member Author

pparage commented Jun 3, 2026

Good catch — valid P2. Fixed in 0439eb9: _detail_at_path now coerces a non-dict manifest top level to {} so CatalogEntryDetail.document: dict validation can't 500 on a syntactically-valid-but-non-mapping manifest (e.g. a JSON/YAML list). The browse walker already tolerates these and still lists the entry, so detail now resolves consistently instead of erroring. Added a regression test (test_detail_non_dict_document_is_coerced_to_dict). Full suite 390 passing.

Minor note: the exact [] example is actually already safe (json.loads('[]') or {}{}); the failure case is a truthy non-dict like [1,2,3]. Fix covers both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant