Skip to content

fix(rivetkit): treat empty actor input bytes as absent - #5529

Open
abcxff wants to merge 1 commit into
mainfrom
stack/fix-rivetkit-treat-empty-actor-input-bytes-as-absent-ouvoqtns
Open

fix(rivetkit): treat empty actor input bytes as absent#5529
abcxff wants to merge 1 commit into
mainfrom
stack/fix-rivetkit-treat-empty-actor-input-bytes-as-absent-ouvoqtns

Conversation

@abcxff

@abcxff abcxff commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@abcxff

abcxff commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@railway-app

railway-app Bot commented Jul 31, 2026

Copy link
Copy Markdown

🚅 Deployed to the rivet-pr-5529 environment in rivet-frontend

Service Status Web Updated (UTC)
frontend-cloud 😴 Sleeping (View Logs) Web Jul 31, 2026 at 4:22 am
frontend-inspector 😴 Sleeping (View Logs) Web Jul 31, 2026 at 4:21 am
kitchen-sink 😴 Sleeping (View Logs) Web Jul 31, 2026 at 4:19 am
website 😴 Sleeping (View Logs) Web Jul 31, 2026 at 4:18 am
ladle ✅ Success (View Logs) Web Jul 31, 2026 at 4:13 am
mcp-hub ✅ Success (View Logs) Web Jul 31, 2026 at 4:13 am

Base automatically changed from stack/revert-rivetkit-core-drop-dangling-http-body-stream-re-exports-nwmvwykt to main July 31, 2026 04:14
@abcxff
abcxff force-pushed the stack/fix-rivetkit-treat-empty-actor-input-bytes-as-absent-ouvoqtns branch from 226de9f to e9dadf6 Compare July 31, 2026 05:27
@abcxff
abcxff force-pushed the stack/fix-rivetkit-treat-empty-actor-input-bytes-as-absent-ouvoqtns branch from e9dadf6 to 0283e79 Compare July 31, 2026 06:03
@claude

claude Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review

Small, well-scoped fix that brings Input<A>::decode()/decode_or() in line with Snapshot::decode() (which already filters empty bytes at start.rs:108) and decode_conn_params (which already special-cases empty bytes at start.rs:529). Confirmed the TS side (native.ts's decodeValue) already treats empty-but-present input bytes as absent, so this change closes a genuine Rust/TS parity gap rather than introducing new behavior.

Potential issue

  • is_present() (start.rs:44) still checks only self.bytes.is_some() and was not updated alongside present_bytes(). After this change, a caller can see is_present() == true for a zero-length-but-Some payload, then call decode() and get Err(MissingInput) (for non-unit input types) or the unit/default value instead of an actual decoded value. "Present" no longer implies "decodable as real data." Since Input is public API in the (preview) rivetkit Rust crate, external callers could reasonably guard on is_present() before calling decode(). Worth considering whether is_present() should also filter empty buffers (delegate to present_bytes().is_some()) for consistency, or document the distinction if it's intentional.

Nits

  • decode_conn_params (start.rs:528) also treats a CBOR-encoded null ([0xf6]) as "use default," but Input::decode/decode_or do not extend the same treatment to a CBOR null payload for actor input. Likely out of scope for this fix (the PR is specifically about the empty-buffer case), but flagging in case the engine can ever send a CBOR null for input the same way it can send an empty buffer.

Test coverage

Good. New tests cover both the "empty bytes defaults" path (input_decode_or_default_treats_empty_bytes_as_missing) and "empty bytes maps to unit" path (input_decode_treats_empty_unit_as_unit), plus a regression test ensuring non-empty invalid CBOR still hard-fails (run_actor_invalid_input_fails_to_start) so the fix doesn't accidentally widen into silently swallowing bad input.

Style

Comments follow the repo convention (complete sentences, no dashes/em-dashes) and the fix mirrors the existing filter idiom already used by Snapshot::decode. No concerns there.

Overall this looks correct and safe to merge; the is_present() inconsistency is the only thing I'd want a second look at before landing.

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