Skip to content

fix: stop masking utils import errors in page_index_md - #498

Open
L4XB wants to merge 1 commit into
VectifyAI:mainfrom
L4XB:fix/page-index-md-import-fallback
Open

fix: stop masking utils import errors in page_index_md#498
L4XB wants to merge 1 commit into
VectifyAI:mainfrom
L4XB:fix/page-index-md-import-fallback

Conversation

@L4XB

@L4XB L4XB commented Sep 9, 2026

Copy link
Copy Markdown

Fixes #486

pageindex/page_index_md.py guarded its relative import with a bare except:. When utils failed to import for a real reason (missing dependency, syntax error), the fallback from utils import * ran instead and, in an installed package, died with ModuleNotFoundError: No module named 'utils', hiding the original traceback.

Change: choose the import form by __package__: inside the package the relative import runs on its own and surfaces its own errors; when the file is executed as a script (no parent package) the sibling utils module is imported as before. No behaviour change for the normal import pageindex.page_index_md path.

Tests (tests/test_page_index_md.py): the script-mode fallback still resolves utils (run in a subprocess from the pageindex/ directory), and the module no longer contains a bare except:.

pytest tests/test_page_index_md.py -q   # 5 passed

The relative-import fallback used a bare `except:`, so when utils failed to
import for a real reason (missing dependency, syntax error) the module
retried `from utils import *`, which in an installed package fails with
"No module named 'utils'" and hides the original error.

Decide the import style by `__package__` instead: package imports use the
relative form and surface their own errors, script mode still resolves the
sibling module.

Fixes VectifyAI#486
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.

[Bug]: Bare except in page_index_md.py masks underlying import and syntax errors

1 participant