Skip to content

fix(workflow)!: return errors for invalid tuple input counts - #800

Merged
geofmureithi merged 1 commit into
apalis-dev:mainfrom
RivTian:fix/graph-tuple-arity
Oct 30, 2026
Merged

geofmureithi merged 1 commit into
apalis-dev:mainfrom
RivTian:fix/graph-tuple-arity

Conversation

@RivTian

@RivTian RivTian commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #799.

When an outer graph input payload decodes successfully but contains the wrong number of tuple elements, GraphCodec::decode currently panics. The same input also makes GraphNodeService::call panic synchronously through NodeInput::Single.

This change returns the existing GraphFlowError::InputCountMismatch { expected, actual } before decoding elements. Invalid input never reaches the handler. Codec failures retain their original source, and successful encoded bytes and element order are unchanged. Node registration accepts graph-input errors independently of backend codec errors.

Compatibility: for 2–12 element tuples, both GraphCodec::encode and decode now return GraphFlowError, and codec errors must implement Into<BoxDynError>. Callers that previously downcast node errors directly to a codec error must follow the source chain. These changes are documented in rustdoc and the changelog.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Refactoring (no functional changes)

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • I have run the existing tests and they pass
  • I have run cargo fmt and cargo clippy

The regression tests failed at runtime against the original implementation at their no-panic assertions. The retained suite now passes all 24 tests, covering 2- and 12-element tuples, synchronous and asynchronous node execution, handler call counts, exact wire bytes, codec error sources, and all three node registration APIs. A NodeInput::FanIn control exercises its separate serde decoding path.

Local validation passed:

cargo test --locked -p apalis-workflow --test graph_tuple_decode_repro --test graph_tuple_node_repro
cargo check --locked --workspace --all-features
cargo test --locked --all
cargo test --locked -p apalis-workflow --no-default-features
cargo test --locked -p apalis-workflow --all-features
cargo clippy --locked --workspace --all-features --all -- -D warnings
cargo fmt --all -- --check
RUSTDOCFLAGS="-D warnings" cargo doc --locked -p apalis-workflow --no-deps --all-features

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

Validation used macOS arm64 and Rust 1.96.0. No dependency, lockfile, or CI workflow changes are included.

Return InputCountMismatch instead of panicking when a decoded graph
input list has the wrong length. Preserve codec failures as error sources
and allow graph nodes to accept GraphCodec errors independently of the
backend codec error type.

Add regression coverage for public decoding and node execution, including
valid wire bytes, handler isolation, and codec error sources.

BREAKING CHANGE: GraphCodec for 2-12 element tuples now uses GraphFlowError
for encode and decode, and codec errors must implement Into<BoxDynError>.
Original codec errors remain accessible through the error source chain.

Fixes apalis-dev#799
@RivTian
RivTian requested a review from geofmureithi as a code owner October 28, 2026 08:58
@geofmureithi
geofmureithi merged commit c14f88e into apalis-dev:main Oct 30, 2026
7 of 8 checks passed
@geofmureithi

Copy link
Copy Markdown
Member

@RivTian thanks for your contribution as always.

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.

[Bug]: Graph tuple input length mismatch panics instead of returning an error

2 participants