Skip to content

fix(serverless): split metadata protocol errors#4789

Closed
NathanFlurry wants to merge 1 commit into04-26-chore_sqlite_add_open_close_lifecycle_for_envoy_actorsfrom
04-24-replay/serverless-metadata-errors
Closed

fix(serverless): split metadata protocol errors#4789
NathanFlurry wants to merge 1 commit into04-26-chore_sqlite_add_open_close_lifecycle_for_envoy_actorsfrom
04-24-replay/serverless-metadata-errors

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

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)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my 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

Copy link
Copy Markdown
Member Author

NathanFlurry commented Apr 27, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 27, 2026

PR Review: fix(serverless): split metadata protocol errors

Overview

This PR improves debuggability of serverless metadata protocol errors by:

  1. Adding max_supported to InvalidEnvoyProtocolVersion so callers know what version to target instead of just what they sent
  2. Propagating parse_error through all SDKs for InvalidResponseJson (the field existed in Rust but was silently dropped at the API boundary)
  3. Regenerating TypeScript, Go, and Rust SDK types consistently
  4. Adding unit tests in engine/packages/pegboard/tests/ and integration tests in engine/packages/engine/tests/

The change is focused and the intent is clear. A few items worth discussing:


Issues

Breaking change for InvalidResponseJsonparse_error is now required

parse_error is added as a required field in the OpenAPI schema for invalid_response_json. The Go SDK new() constructor now requires it as a second argument. Any existing consumer constructing this type directly will break at compile time. This is probably fine given the context, but worth confirming no internal callers are affected.

Flaky potential in refresh_metadata test (line 248)

tokio::time::timeout(Duration::from_millis(100), async {
    // assert cache was invalidated
})

This assumes cache invalidation completes within 100 ms. In a CI environment under load this could race. Since the operation is a direct cache read (not a poll), await-ing the assertion directly without a timeout would be more robust. If a timeout is intentional to catch a "cache was not invalidated" regression, a comment explaining that would help, and the timeout should be longer.

Hand-rolled HTTP server buffer in serverless_metadata_fetch.rs

let mut buf = [0; 1024];
let _ = socket.read(&mut buf).await;

The 1024-byte buffer can be exceeded on some platforms/reqwest versions when headers like user-agent, accept, and keep-alive accumulate. Consider a Vec-based drain loop or using axum (as the integration test files already do).


Observations

No test for protocol version 0 or exactly PROTOCOL_VERSION

The guard is envoy_protocol_version < 1 || envoy_protocol_version > PROTOCOL_VERSION. There is a test for PROTOCOL_VERSION + 1 (too high) but none for 0 (too low) or PROTOCOL_VERSION itself (exact valid boundary). Adding these would make boundary behavior explicit.

run and setup_test_namespace duplicated across both new test files

Both new integration test files copy-paste an identical run helper and setup_test_namespace. The existing common/api/public.rs pattern shows this codebase uses #[path] includes — run could live in common/ctx.rs or a new common/test_utils.rs.

i32 in Rust SDK vs u16 in source

RunnerConfigsServerlessMetadataErrorOneOf6InvalidEnvoyProtocolVersion uses i32 for max_supported and version while the Rust source uses u16. This is expected from code generation (int32 + minimum: 0), but a version number > 32767 would overflow/sign-flip in SDK consumers.

MockMetadataErrorState naming

The struct name implies an error state, but it is also used for the valid-JSON-with-invalid-version case. A name like MockRawBodyState would be more neutral.


Positive notes

  • Tests are correctly placed under tests/ following the repo convention.
  • AtomicBool with Ordering::SeqCst is correct for the cross-thread mock server visibility.
  • The CLAUDE.md addition about engine/sdks/*/api-* being auto-generated is a useful guardrail.
  • All three SDKs (Go, Rust, TypeScript) are updated consistently; the TypeScript core.serialization.property snake_case mapping is handled correctly.
  • Removing the // Re-export types from pegboard for API schema comment follows the project's no-delta-comments convention.

@github-actions
Copy link
Copy Markdown
Contributor

Preview packages published to npm

Install with:

npm install rivetkit@pr-4789

All packages published as 0.0.0-pr.4789.1e19894 with tag pr-4789.

Engine binary is shipped via @rivetkit/engine-cli on linux-x64-musl, linux-arm64-musl, darwin-x64, and darwin-arm64. Windows users should use the release installer or set RIVET_ENGINE_BINARY.

Docker images:

docker pull rivetdev/engine:slim-1e19894
docker pull rivetdev/engine:full-1e19894
Individual packages
npm install rivetkit@pr-4789
npm install @rivetkit/react@pr-4789
npm install @rivetkit/rivetkit-napi@pr-4789
npm install @rivetkit/workflow-engine@pr-4789

@NathanFlurry NathanFlurry changed the base branch from 04-26-chore_sqlite_add_open_close_lifecycle_for_envoy_actors to graphite-base/4789 April 27, 2026 03:24
@NathanFlurry NathanFlurry force-pushed the 04-24-replay/serverless-metadata-errors branch from f59dc09 to 57aec7d Compare April 27, 2026 03:27
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4789 to 04-26-chore_sqlite_add_open_close_lifecycle_for_envoy_actors April 27, 2026 03:27
@NathanFlurry NathanFlurry force-pushed the 04-26-chore_sqlite_add_open_close_lifecycle_for_envoy_actors branch from cccd897 to 603deec Compare April 27, 2026 03:59
@NathanFlurry NathanFlurry force-pushed the 04-24-replay/serverless-metadata-errors branch 2 times, most recently from 0121259 to 65d08ca Compare April 27, 2026 04:35
@NathanFlurry NathanFlurry force-pushed the 04-24-replay/serverless-metadata-errors branch from 65d08ca to 581f2f1 Compare April 27, 2026 05:37
@NathanFlurry NathanFlurry force-pushed the 04-24-replay/serverless-metadata-errors branch 2 times, most recently from d60686a to a6dc766 Compare April 27, 2026 07:57
@NathanFlurry NathanFlurry force-pushed the 04-26-chore_sqlite_add_open_close_lifecycle_for_envoy_actors branch from 603deec to 40afd97 Compare April 27, 2026 07:57
@NathanFlurry NathanFlurry marked this pull request as ready for review April 27, 2026 07:59
@NathanFlurry NathanFlurry force-pushed the 04-24-replay/serverless-metadata-errors branch from a6dc766 to a3da1d9 Compare April 27, 2026 08:31
@NathanFlurry NathanFlurry force-pushed the 04-26-chore_sqlite_add_open_close_lifecycle_for_envoy_actors branch from 4c2f41a to fc09194 Compare April 27, 2026 17:35
@NathanFlurry NathanFlurry force-pushed the 04-24-replay/serverless-metadata-errors branch from a3da1d9 to b69ce64 Compare April 27, 2026 17:35
@NathanFlurry NathanFlurry force-pushed the 04-26-chore_sqlite_add_open_close_lifecycle_for_envoy_actors branch from fc09194 to 53de8fb Compare April 27, 2026 19:06
@NathanFlurry NathanFlurry force-pushed the 04-24-replay/serverless-metadata-errors branch 2 times, most recently from 14c2718 to 383f617 Compare April 27, 2026 19:40
@NathanFlurry NathanFlurry force-pushed the 04-24-replay/serverless-metadata-errors branch from 383f617 to 4e0624f Compare April 27, 2026 20:48
@NathanFlurry NathanFlurry force-pushed the 04-26-chore_sqlite_add_open_close_lifecycle_for_envoy_actors branch from 53de8fb to 376b5c9 Compare April 27, 2026 20:48
@NathanFlurry
Copy link
Copy Markdown
Member Author

Landed in main via stack-merge fast-forward push. Commits are in main; closing to match.

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