fix(dsl-engine): de-noise python pipeline load errors#149
Open
markovejnovic wants to merge 1 commit into
Open
Conversation
When a user's `.hm/*.py` raised at import time (a removed kwarg, a typo,
a bad import), the render surfaced the raw CPython traceback — the
harness `<string>` frame and `<frozen importlib._bootstrap>` machinery
the user can't act on:
rendering pipeline via python3: python3 exited with code 1:
Traceback (most recent call last):
File "<string>", line 11, in <module>
File "<frozen importlib._bootstrap_external>", line 759, in exec_module
...
TypeError: pipeline() got an unexpected keyword argument 'default_image'
Factor the three render scripts onto a shared bootstrap that catches
load-time exceptions and reports only what's actionable — the offending
file, the exception, and the user-code frames — dropping the harness and
importlib frames:
error: failed to load pipeline file '.hm/ci.py'
TypeError: pipeline() got an unexpected keyword argument 'default_image'
at .hm/ci.py:66 in <module>
Matches the project's error-message doctrine: point precisely, state
what was observed, fail fast.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a user's
.hm/*.pyraises at import time — a removed kwarg (e.g.default_image, see #147/#148), a typo, a bad import — the render leaks the raw CPython traceback, including the harness<string>frame and the<frozen importlib._bootstrap>machinery the user can't act on:This is the failure prod has been surfacing on builds, and it violates the error-message doctrine (point precisely, state what was observed, fail fast — no noise).
Fix
Factor the three render scripts (
list/registry/render) onto a shared bootstrap (_load_pipelines) that wrapsexec_moduleand, on failure, reports only what's actionable — the offending file, the exception, and the frames inside the user's own pipeline file — dropping the harness and importlib frames:Frame matching tolerates relative/absolute path differences so the precise line always shows.
This is the general fix; #148 separately restores
default_imageas a deprecation shim so that specific kwarg keeps working during the grace period. Together: old pipelines keep rendering, and any future load-time error reads cleanly.Tests
tests/python_engine_test.rs::python_load_error_is_denoised— a pipeline file that raises at import yields an error that names the file, surfaces the exception, points at the failing line (ci.py:3), and contains no_bootstrap/exec_moduleframes.Crate: all tests pass; clippy
-D warningsclean.