The GitHub Actions job "CI" on tvm-ffi.git/structural-error-context has succeeded. Run started by GitHub user tqchen (triggered by tqchen).
Head commit for run: 2d2d1c90dba47aa182b95be712db20188d5ac4fb / tqchen <[email protected]> [EXTRA][FEAT] StructuralErrorContext for structural-context-aware error reporting When code throws while recursively visiting an Object tree, the resulting error message lacks position context — the user sees what went wrong but not where in the tree. This change adds a typed payload to attach the visit chain to Error and resolve it to a structured access path. Expected usage A visitor or checker instruments each visit level with the BEGIN/END macros, throws via the THROW variant at the deepest detection point, and resolves the recorded chain at the visit root. void MyChecker::Visit(const ObjectRef& node) { TVM_FFI_STRUCTURAL_VISIT_BEGIN(); if (BadShape(node)) { TVM_FFI_STRUCTURAL_VISIT_THROW(TypeError, node) << "rank mismatch"; } DispatchVisitFields(node); TVM_FFI_STRUCTURAL_VISIT_END(node); } void Check(const ObjectRef& root) { try { visitor.Visit(root); } catch (Error& err) { auto sc = StructuralErrorContext::TryGetFromError(err); if (sc) { auto paths = StructuralErrorContext::FindAccessPaths(root, sc.value()); // paths describes WHERE in root the error fired, e.g. // Root -> Attr("body") -> ArrayItem(2) -> Attr("cond") -> Attr("lhs") // Use it to enrich the message with structured position info. } throw; } } THROW seeds the StructuralErrorContext with the throw site as the innermost frame; surrounding BEGIN/END pairs append parent nodes on rethrow as the stack unwinds. FindAccessPaths walks root via reflection, normalizes the recorded pattern (drops nulls, collapses consecutive duplicates that arise when THROW and END both record the same node), and returns one or more AccessPaths whose innermost step points at the throw site. API - StructuralErrorContext: typed payload in tvm/ffi/extra/, with a mutable List<ObjectRef> reverse_visit_pattern (innermost-first breadcrumb trail) and an optional previous_error_context (preserved when wrapping a pre-existing payload in extra_context). - TVM_FFI_STRUCTURAL_VISIT_BEGIN / TVM_FFI_STRUCTURAL_VISIT_END(node): instrument visit dispatch. On rethrow, END appends node to the in-flight Error's StructuralErrorContext. - TVM_FFI_STRUCTURAL_VISIT_THROW(kind, node) << "msg": throw an Error with the StructuralErrorContext pre-attached. No separate update call needed at the throw site. - StructuralErrorContext::FindAccessPaths(root, ctx, allow_prefix_match): walks root via reflection and returns Array<AccessPath> for matched positions. Strict full-match by default; allow_prefix_match=true reports the deepest prefix when the innermost frame is unreachable. - StructuralErrorContext::TryGetFromError(err): inline helper to fetch the payload from an Error, NullOpt if absent. ABI No ABI changes. Reuses the existing Error::extra_context slot via existing ObjectUnsafe patterns. Tests cover macro-builds-chain for both BEGIN/END and THROW variants, FindAccessPaths correctness (basic match, all access kinds, sparse anchors, partial-chain prefix matching, edge cases), records cleanup (null and dup-consecutive normalization), and TryGetFromError composition. Report URL: https://github.com/apache/tvm-ffi/actions/runs/25807278315 With regards, GitHub Actions via GitBox --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
