Skip to content

fix(protoapp): propagate binding errors to plugins via lastError API#25

Merged
pabloinigoblasco merged 1 commit into
developmentfrom
fix/protoapp-binding-error-propagation
Apr 2, 2026
Merged

fix(protoapp): propagate binding errors to plugins via lastError API#25
pabloinigoblasco merged 1 commit into
developmentfrom
fix/protoapp-binding-error-propagation

Conversation

@pabloinigoblasco
Copy link
Copy Markdown
Collaborator

@pabloinigoblasco pabloinigoblasco commented Apr 1, 2026

Summary

When ensureParserBinding() fails, plugins need to know why it failed to show meaningful error messages. The SDK provides the lastError() API for this purpose, but the protoapp implementation always returned nullptr.

Before this fix

Plugins received empty error strings:

No channels could be bound to parsers:
  - /camera/image (encoding: ros1):

Users couldn't distinguish between:

  • "Parser not installed" (they can install it)
  • "Schema corrupted" (the file has a problem)
  • "Internal parser error" (a bug)

After this fix

Plugins show actionable messages:

No channels could be bound to parsers:
  - /camera/image (encoding: ros1): no parser found for encoding 'ros1'
  - /bad/data (encoding: cdr): failed to parse broken_msgs/Garbage: Missing ROSType

Technical details

The SDK uses a C ABI for plugin ↔ host communication. When ensure_parser_binding() returns false, the SDK wrapper calls get_last_error() to populate the Expected<Handle> error message. This contract was already designed correctly — the bug was that rhGetLastError() always returned nullptr.

Changes

File Change
data_source_session.hpp Add std::string last_error to RuntimeHostState
data_source_session.cpp Store error message at each of 5 failure points
data_source_session.cpp Return state->last_error from rhGetLastError()

Failure points now covered

  1. No parser found for encoding
  2. Failed to create parser instance
  3. Failed to create topic in datastore
  4. Failed to bind write host to parser
  5. Failed to parse schema (includes parser's lastError)

Impact

Enables MCAP, Foxglove Bridge, and PJ Bridge plugins to report binding failures with context. No SDK changes required.

Test plan

  • Load MCAP with unsupported encoding → verify error message shows encoding name
  • Load MCAP with malformed schema → verify error message shows parse failure details

When ensureParserBinding() fails, plugins need to know WHY it failed
to show meaningful error messages to users. The SDK already provides
the lastError() API for this purpose, but the protoapp implementation
always returned nullptr.

Problem:
- rhGetLastError() returned nullptr unconditionally
- Plugins received empty error strings: "/topic (encoding: ros1): "
- Users couldn't distinguish between "parser not installed" vs
  "schema corrupted" vs "internal parser error"

Solution:
- Add last_error field to RuntimeHostState
- Store descriptive error message at each failure point in
  rhEnsureParserBinding (5 failure points total)
- Return stored error from rhGetLastError()

Now plugins show actionable messages:
  "/topic (encoding: ros1): no parser found for encoding 'ros1'"
  "/bad (encoding: cdr): failed to parse schema: Missing ROSType"

This enables MCAP, Foxglove Bridge, and PJ Bridge plugins to report
binding failures with context, helping users diagnose missing parsers
or malformed schemas.

No SDK changes required - this implements the existing lastError()
contract that the protoapp was not fulfilling.
@pabloinigoblasco pabloinigoblasco merged commit c1a1bd9 into development Apr 2, 2026
2 checks passed
@pabloinigoblasco pabloinigoblasco deleted the fix/protoapp-binding-error-propagation branch April 2, 2026 00:21
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