Skip to content

feat(c++/operator): wire InputParseError to a C++ callback (residual phase-5 gap) #1879

@heyong4725

Description

@heyong4725

Summary

Surfaced while closing #993 (C++ roadmap completeness audit). All seven of @PavelGuzenfeld's roadmap phases substantially landed, except a narrow event-type gap in the C++ operator FFI surface.

The gap

The Rust operator API exposes 4 event variants at apis/rust/operator/src/lib.rs:34-48:

pub enum Event<'a> {
    Input { id, metadata, data },
    InputParseError { id, error },
    InputClosed { id },
    Stop,
}

The C++ operator FFI at apis/c++/operator/src/lib.rs only dispatches 3:

  • on_input(...)
  • on_input_closed(...)
  • on_stop(...)

There is no on_input_parse_error(...) callback. InputParseError is actively emitted at apis/rust/operator/src/raw.rs:55 when input deserialization fails, so the Rust-side error path is real, not dead code. Today a C++ operator that receives a malformed input gets silence where its Rust counterpart would get an explicit error event it could log, surface as health, or reroute.

Why this is bounded

  • One file structurally affected on the C++ FFI side (apis/c++/operator/src/lib.rs).
  • One file on the wrap-the-event-stream side that needs the new dispatch arm.
  • One docs file to update (docs/api-cxx.md "Operator API" section already lists 3 callbacks; add the fourth).
  • One header symmetry update for the C operator API (apis/c/operator/operator_api.h) since the C surface has the same gap.

Proposed shape

Mirror the existing on_input callback declaration in apis/c++/operator/src/lib.rs:

fn on_input_parse_error(
    op: Pin<&mut Operator>,
    id: rust::Str,
    error: rust::Str,
    output_sender: &mut OutputSender,
) -> DoraOnInputResult;

And add a matching dispatch arm in the event loop that runs ffi::on_input_parse_error(...). Consumers (C++ operators) opt in by implementing the function; backward compat is preserved by also accepting a weak symbol or a default-no-op shim — maintainer call on the exact compat shape.

For the C operator API, parallel surface in apis/c/operator/operator_api.h.

Verification

Add a small smoke test under tests/cmake-find-package-operator-cxx/ or a new tests/operator-input-parse-error-cxx/ that:

  1. Builds an operator that records every event type via the new callbacks.
  2. Feeds it a deliberately malformed input.
  3. Asserts the on_input_parse_error callback received the expected id + error.

The C/C++ smoke fixtures added in #1875 are a good shape to copy from.

Credit chain

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions