Skip to content

fix(core): skip a page whose category has no usable schema - #209

Open
LukasGold wants to merge 1 commit into
fix/load-entity-registered-classfrom
fix/202-category-loop-error-handling
Open

LukasGold wants to merge 1 commit into
fix/load-entity-registered-classfrom
fix/202-category-loop-error-handling

Conversation

@LukasGold

Copy link
Copy Markdown
Contributor

Closes #202.

Stacked PR

This targets fix/load-entity-registered-class, the head of
#166, not main. PR #166
rewrites the same block, so a branch off main would conflict with it. Merge
#166 first, then retarget this one to main.

Review only the single commit fix(core): skip a page whose category has no usable schema.

Changes

  • The body of for category in jsondata["type"]: in load_entity is wrapped
    in try / except Exception.
  • The handler sets schemas_fetched = False, logs the page title, the
    category and the exception with _logger.error, and continues.
  • The existing if not schemas_fetched: continue then skips the page.
  • New offline test file tests/test_load_entity_bad_category.py.

Read the source change with git diff -w. Most of the 100 changed lines are
indentation. Two lines were reflowed by ruff format because the added
indentation level pushed them past 88 columns.

Rationale

The schema title was read outside any error handling, so three inputs ended
the whole call:

Input Exception
the category page has no jsonschema slot, so get_slot_content returns None TypeError: 'NoneType' object is not subscriptable
the schema has no title key KeyError: 'title'
title is present but not a string TypeError: attribute name must be string

For a multi-title load this meant the titles after the bad one were never
processed, and the message named neither the page nor the category.

Two error paths in the same function already handle a page-level fault this
way: the missing-model branch sets schemas_fetched = False and logs, and the
entity construction below catches Exception, logs with the page title, and
lets the loop continue. The handler added here follows both. Exception is
caught rather than the three specific types, to match the construction block
and to cover any other fault in a category page.

Verification

  • All five new tests were run against the unfixed source first and fail there,
    with TypeError: 'NoneType' object is not subscriptable from the line the
    issue names.
  • pytest tests -q on this branch: 674 passed. The count is lower than on
    main because the base branch does not yet contain the most recent main
    commits.
  • make check: pre-commit, ruff, ty and deptry all pass.

The tests cover the three inputs above, a two-title load where the first page
is broken and the second entity is still returned, and an assertion that the
logged error names both the page and the category.

- the category loop read the schema title outside any try, so a category
  page with no jsonschema slot, no title key, or a non-string title
  ended load_entity and left the remaining titles unloaded
- the loop body is now wrapped in try/except, which logs the page title,
  the category and the exception, then skips the page like the two error
  paths that already exist in the same function

Closes #202
@github-actions

Copy link
Copy Markdown
Contributor

Release preview

No version bump from the current commits (stays at v2.6.0). Use conventional commit types (feat, fix, ...) to trigger a release.

Changelog preview (truncated)

Preview via python-semantic-release and conventional commits.

@LukasGold LukasGold self-assigned this Sep 23, 2026
@LukasGold LukasGold added the enhancement New feature or request label Sep 23, 2026

This branch has not been deployed

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant