Skip to content

fix(io): make event import iteration fallible - #537

Merged
rapids-bot[bot] merged 2 commits into
rapidsai:mainfrom
johanpel:schema-based-event-import-iterator-fallible-importers
Aug 6, 2026
Merged

fix(io): make event import iteration fallible#537
rapids-bot[bot] merged 2 commits into
rapidsai:mainfrom
johanpel:schema-based-event-import-iterator-fallible-importers

Conversation

@johanpel

@johanpel johanpel commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

Make importers yield Result items so read, framing, and decoding failures are not mistaken for EOF. Recover when the next record boundary is known, otherwise terminate after returning the error.

Generated model and query-engine consumers now propagate item errors. Simulator bridges temporarily collect streams until a follow-up introduces the fallible streaming interface in #520.

Related Issues

Split off as a small incremental change from #520

Written by Codex.

Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
@johanpel
johanpel force-pushed the schema-based-event-import-iterator-fallible-importers branch from c64b261 to 0e56a9f Compare August 6, 2026 06:53
@johanpel johanpel changed the title fix(io): make event import iteration fallible (WIP) fix(io): make event import iteration fallible Aug 6, 2026
@johanpel
johanpel marked this pull request as ready for review August 6, 2026 07:05
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Importer contracts now expose per-event errors. MessagePack, NDJSON, and Postcard readers propagate read and deserialization failures. Generated model imports and query-engine and simulator consumers handle result-wrapped iterator items.

Changes

Importer error propagation

Layer / File(s) Summary
Importer contracts and exports
crates/io/types/src/lib.rs, crates/io/src/lib.rs
ImporterError now supports boxed errors and I/O conversion. Importer yields ImporterResult<Event<T>>, MAX_FRAME_SIZE_BYTES is public, and Exporter is publicly re-exported.
Format importer error handling
crates/io/msgpack/src/lib.rs, crates/io/ndjson/src/lib.rs, crates/io/postcard/src/lib.rs
Importers return read and deserialization errors, enforce frame limits where applicable, distinguish clean EOF from incomplete input, and stop after terminal failures.
Generated model import mapping
crates/model-macros/src/model_macro.rs
Generated import_events preserves importer errors while converting successful payloads into model events.
Consumer result handling
domains/query_engine/server/src/analyzer_cache.rs, examples/simulator/analyzer/src/lib.rs, examples/simulator/server/src/main.rs
Consumers unwrap, collect, and convert result-wrapped imported events as required by their APIs.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Suggested reviewers: dhruv9vats, joosthooz, cmatzenbach, mbrobbel, 9prady9

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: making event import iteration fallible.
Description check ✅ Passed The description explains the change and related issue, but it does not include the template's Testing or Screenshots sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/io/msgpack/src/lib.rs`:
- Around line 160-164: Define a shared supported maximum frame size, then update
the payload-reading logic in crates/io/msgpack/src/lib.rs lines 160-164 and
crates/io/postcard/src/lib.rs lines 159-163 to reject lengths above it before
allocation and use fallible allocation for payload buffers; return the existing
importer failure for either oversized frames or allocation errors, while
preserving normal read_exact handling.

In `@crates/io/types/src/lib.rs`:
- Around line 85-92: Replace the public ImporterError type alias with a concrete
thiserror enum, including an explicit other variant for format-specific decode
errors. Update importer implementations and decoder error conversions to wrap
those errors through the enum, while preserving Send + Sync compatibility and
the ImporterResult contract.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: 83d01151-d1cc-4332-af90-eead1bf8ab43

📥 Commits

Reviewing files that changed from the base of the PR and between 0c92602 and 0e56a9f.

📒 Files selected for processing (9)
  • crates/io/msgpack/src/lib.rs
  • crates/io/ndjson/src/lib.rs
  • crates/io/postcard/src/lib.rs
  • crates/io/src/lib.rs
  • crates/io/types/src/lib.rs
  • crates/model-macros/src/model_macro.rs
  • domains/query_engine/server/src/analyzer_cache.rs
  • examples/simulator/analyzer/src/lib.rs
  • examples/simulator/server/src/main.rs

Comment thread crates/io/msgpack/src/lib.rs
Comment thread crates/io/types/src/lib.rs Outdated
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

🟡 Other comments (1)
crates/io/types/src/lib.rs-85-86 (1)

85-86: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document the public ImporterError contract.

ImporterError is a new public enum. Add a concise type-level doc comment that states when callers receive it. Public visibility is required because ImporterResult exposes this type.

Proposed fix
+/// Errors returned while importing events.
 #[derive(Debug, Error)]
 pub enum ImporterError {

As per path instructions, new pub items need a doc comment and justified visibility.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/io/types/src/lib.rs` around lines 85 - 86, Add a concise Rust doc
comment directly above the public ImporterError enum describing when callers
receive this error, preserving its existing variants and visibility because
ImporterResult exposes it.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/io/msgpack/src/lib.rs`:
- Around line 164-181: Extract the duplicated frame-limit validation, buffer
allocation, and read_exact logic into a documented helper in quent-io-types that
accepts a Read implementation and length and returns ImporterResult<Vec<u8>>;
update crates/io/msgpack/src/lib.rs lines 164-181 and
crates/io/postcard/src/lib.rs lines 163-180 to call it after decoding the frame
length, while keeping each importer’s self.fail handling local.

---

Other comments:
In `@crates/io/types/src/lib.rs`:
- Around line 85-86: Add a concise Rust doc comment directly above the public
ImporterError enum describing when callers receive this error, preserving its
existing variants and visibility because ImporterResult exposes it.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: 01a3c5ee-04a0-420b-b767-a50d18562311

📥 Commits

Reviewing files that changed from the base of the PR and between 0e56a9f and d884aeb.

📒 Files selected for processing (4)
  • crates/io/msgpack/src/lib.rs
  • crates/io/ndjson/src/lib.rs
  • crates/io/postcard/src/lib.rs
  • crates/io/types/src/lib.rs

Comment thread crates/io/msgpack/src/lib.rs

@dhruv9vats dhruv9vats left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@johanpel

johanpel commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 92778bb into rapidsai:main Aug 6, 2026
20 checks passed
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.

2 participants