Skip to content

fix(dsl-engine): de-noise python pipeline load errors#149

Open
markovejnovic wants to merge 1 commit into
mainfrom
fix/render-error-denoise
Open

fix(dsl-engine): de-noise python pipeline load errors#149
markovejnovic wants to merge 1 commit into
mainfrom
fix/render-error-denoise

Conversation

@markovejnovic

Copy link
Copy Markdown
Contributor

Problem

When a user's .hm/*.py raises 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:

render failed (exit 1): rendering pipeline "ci": 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
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "/tmp/co/.hm/ci.py", line 66, in <module>
    @hm.pipeline(
  ...
TypeError: pipeline() got an unexpected keyword argument 'default_image'

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 wraps exec_module and, 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:

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>

Frame matching tolerates relative/absolute path differences so the precise line always shows.

This is the general fix; #148 separately restores default_image as 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_module frames.

Crate: all tests pass; clippy -D warnings clean.

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.
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