refactor: commands raise; cli.main is the sole error emitter - #117
Merged
Conversation
This was referenced Aug 13, 2026
DLANSAMA
force-pushed
the
refactor/aaa-pr8-error-path
branch
from
August 13, 2026 02:45
456cd9f to
565f7e6
Compare
DLANSAMA
force-pushed
the
refactor/aaa-pr7-test-stubs
branch
2 times, most recently
from
August 13, 2026 04:03
3d42e67 to
4befde7
Compare
Domain handlers abort() with extra envelope keys on BambuError. write_error_envelope is the only JSON error writer. Remaining emit_json_error call sites raise via abort so they cannot emit twice. Job reads the exception instead of the last-error global.
abort("") dropped the step, so plate download --json not-a-url emitted
an envelope without failed_step and the contract test failed.
emit_json_error now logs and records extras before raising, so download URL validation still redacts credentials and names failed_step. URL checks abort with a real message instead of "Command failed (exit N)". RuntimeContext.printer() uses get_printer() when it is the installed context so the one factory is the patch point. Setup, preflight, and setup --migrate-access-code emit through Contract objects. Domain commands no longer write JSON envelopes; tests inspect BambuError extras and cli.main remains the sole stdout writer.
DLANSAMA
force-pushed
the
refactor/aaa-pr8-error-path
branch
from
August 13, 2026 04:12
90f218f to
308345f
Compare
DLANSAMA
added a commit
that referenced
this pull request
Aug 14, 2026
* refactor: printer factory, MQTT/FTPS hardening, coverage to 86 Continues the boundary/error-model arc (#117/#118). Architecture: - RuntimeContext.printer() now uses an injectable factory registered downward from bambu_cli.printer (set_printer_factory); context.py no longer imports printer. Removes the last check_layers ALLOWED edge (context -> printer); ALLOWED is now empty. Correctness / resources: - mqtt_session: lock _pending_payload/_command_issued across the paho network thread; cached-complete-snapshot fast path on silent pushall. - mqtt_tls: drop global socket.setdefaulttimeout mutation; bound connect via client._connect_timeout; configurable, validated MQTTS port. - mqtt_cmd/mqtt_print/mqtt_monitor: teardown in finally (fixes leak on the connect-exception path). - ftps: close the socket if connect/login/prot_p fails. - snapshot/slice: drop unreachable safe_log_error+abort tails after emit_json_error (now typed NoReturn); it already logs and raises. Tests / CI: - +40 targeted tests for the above error paths; raise CI cov floor 83 -> 86 (measured 91.0% Linux). Stronger docs-coverage drift guard. - Docs: api.md support matrix; SECURITY.md residuals marked accepted for 1.0; scoreboard refreshed. * test: make preflight perms test platform-aware (Windows CI) _file_permission_check returns None on win32 by design (POSIX mode bits don't apply — see the Windows secret ACLs residual in SECURITY.md), so the 0o644/0o600 assertions only hold off-Windows. Assert the None path on win32 instead. --------- Co-authored-by: DLANSAMA <258674612+DLANSAMA@users.noreply.github.com>
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.
AAA stack 8/9. Stacked on #116.
Domain code raises
BambuError/abort(..., extra=).cli.mainis the only place that writes the--jsonerror envelope (write_error_envelope).emit_json_errorbecomes a thin raise wrapper so leftover call sites do not emit-then-abort.BambuError.extra/to_error_payload()carry machine-readable extras (failed_step, redactedsource,extension, …) sojoband tests can rebuild the envelope without reading stdout.Stack: #110 → #111 → #112 → #113 → #114 → #115 → #116 → this → honesty