fix(documents): preserve native template failure causes

Merged
MA
6h ago
+47-2

Problem

The shared coded-result adapter caught native DOCX/PPTX template failures and kept only the formatted message. Public renderers propagated an incomplete failure, so callers lost the exception identity and native traceback.

Implemented correction

The adapter now passes the caught exception to the existing r.fail(..., exception=exc) owner. The caught exception types, domain code/message and success path remain unchanged.

Two regressions exercise the public u.Cli.docx_render and u.Cli.render_presentation facades with real ZIP packages missing mandatory OPC metadata. They require the original KeyError, its traceback and the same exception instance when reading result.value. The DOCX regression also verifies that the innermost traceback frame belongs to the native zipfile module, using public inspection APIs.

Current integration candidate

Head 8f673ff9753bccf144a74812e06716723aa3a11b is a normal two-parent merge of the corrected head and current integration fb8658f83f69ab039c34c9a69782104c0d7cdc3c. Tree: f0a387271e213d446cd862cbc1a0f8d4e36911a7.

The three reviewed PR files are unchanged. The integration delta adds the already merged YAML-template and process-diagnostic corrections in disjoint paths.

Current CI 47657640625, job 146107644605 tested merge 6e1e3a23b6afd107141dac3da827b81c19871091, with the exact candidate tree above and parents [fb8658f8, 8f673ff9]. Setup passed; lint and Pyrefly reported zero errors. 1,431 tests passed, 70 deselected in 33.14 seconds. Both template-cause regressions passed. Sonar and Semgrep passed. Cubic recognized this final commit as a merge and reused the existing review; no new source review is attributed to that skipped review. Both review threads are resolved.

Native RED and GREEN

RED: CI 47655725511, job 146101558399 tested regression-only head c9be58ce2aa077ced3bc4356a48864c09e2b214e through merge 72ec90f7521623aa7d9a2fd926a574130c11003b. Setup and check passed. DOCX failed with Expected KeyError, got NoneType: 1 failed, 6 passed, 70 deselected in 4.48 seconds. The ordinary fail-fast policy stopped before the PPTX regression. The workflow's existing second tests step repeated that failure within the same attempt; no rerun was requested.

GREEN: CI 47656773673, job 146104921293 tested corrected head bef2a3bb3611f49015b6d3e5b7b0299062b6aa8c through merge 76d7bfd1b1c7be3b85174bab0f3a1062d111626a, which includes integration 95e8c0cc21a3f21b6aae86c758cc59d2a17fc5cf. Setup, lint and Pyrefly passed. 1,411 tests passed, 70 deselected in 39.19 seconds. Both new regressions passed. Tested tree: f967c37418906efb31bbc5e20f3179b52f38f2f3.

The corrected head also passed Sonar, Semgrep and Cubic. The earlier traceback review was addressed by the native-frame assertion. Independent source reviews checked the owner and public propagation. Runtime qualification used the ordinary native CI only.

Scope

The production change is one line in the shared adapter. Tests use real native parsers and public project contracts. No mock, private project interface, compatibility alias, generated projection or lock change is introduced. Separate direct exception catches remain follow-up work.

Traceability

Version: 1.3
Date: 2026-12-06
Author: Marlon Costa marlon.costa@datacosmos.com.br — Datacosmos


Summary by cubic

Preserves the native exception, traceback, and exception identity when DOCX/PPTX template rendering fails, so result.exception and result.value no longer lose the original failure.

  • The coded-result adapter now passes the caught exception through r.fail(..., exception=exc) instead of keeping only the formatted message.
  • Regression tests feed malformed OPC ZIP templates through the public docx_render and render_presentation facades and require the native KeyError, its traceback, and the same exception instance on result.value.
  • The DOCX regression also verifies the innermost traceback frame belongs to the native zipfile module.