Skip to content

test(serverless): avoid pinning header validation order#4896

Merged
NathanFlurry merged 1 commit intomainfrom
driver-test-complaints/loosen-serverless-header-test
May 4, 2026
Merged

test(serverless): avoid pinning header validation order#4896
NathanFlurry merged 1 commit intomainfrom
driver-test-complaints/loosen-serverless-header-test

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 May 3, 2026

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

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 3, 2026

PR 4896 Review - test(serverless): avoid pinning header validation order

Note: This PR is currently in DRAFT status.

Overview

This PR fixes two related issues: the Rust fallback logic for the deprecated x-rivet-runner-name header was producing a misleading error message when neither header was present, and the test was brittle because it pinned a specific header validation order.


Rust change (rivetkit-core/src/serverless.rs)

Root cause fixed: The old chain used required_header().or_else(|_| required_header()), which meant when neither header was present, the error came from the fallback call and said "x-rivet-runner-name header is required" instead of the canonical "x-rivet-pool-name header is required". The new code always surfaces the canonical name. Correct fix.

Suggestion - simplify to idiomatic Option::or_else: The match block can be replaced with an optional_header().or_else().ok_or_else() chain. This avoids explicit match arms and is more idiomatic Rust for "try A, fall back to B, error if neither."


Test change (tests/driver/serverless-handler.test.ts)

Indentation issue: The closing }); for toMatchObject and the subsequent expect call are both indented one level too deep, at the object-content level rather than the call level. This is syntactically valid but visually implies the second expect is nested inside the first. Consider re-indenting for clarity.

Optional chaining on a required field: body.metadata?.reason uses ?. on metadata, which should always be present in an invalid_request response. If metadata is absent, expect(undefined).toMatch(regex) fails with "received value must be a string" rather than a clear missing-field error. Prefer body.metadata.reason.

Regex scope is appropriate: Matching any of the three possible required header names avoids pinning to a specific validation order, which is exactly the goal of this PR.


Summary

Item Severity
Rust: simplify match to or_else chain Minor (style)
Test: }); indented at wrong level Minor (formatting)
Test: ?. on always-present metadata field Minor

The core logic fix is correct. The suggestions above are minor style and quality improvements.

@NathanFlurry NathanFlurry force-pushed the driver-test-complaints/stub-preload-hints branch from 1000bc4 to afafe22 Compare May 3, 2026 00:54
@NathanFlurry NathanFlurry force-pushed the driver-test-complaints/loosen-serverless-header-test branch from c9ab192 to 6ddb158 Compare May 3, 2026 00:54
@NathanFlurry NathanFlurry marked this pull request as ready for review May 3, 2026 03:57
@NathanFlurry NathanFlurry marked this pull request as draft May 3, 2026 07:19
@NathanFlurry NathanFlurry force-pushed the driver-test-complaints/stub-preload-hints branch from afafe22 to 7cff899 Compare May 3, 2026 07:34
@NathanFlurry NathanFlurry force-pushed the driver-test-complaints/loosen-serverless-header-test branch from 6ddb158 to 44367cd Compare May 3, 2026 07:34
@NathanFlurry NathanFlurry changed the base branch from driver-test-complaints/stub-preload-hints to graphite-base/4896 May 3, 2026 21:03
@NathanFlurry NathanFlurry force-pushed the driver-test-complaints/loosen-serverless-header-test branch from 44367cd to 20f0389 Compare May 3, 2026 21:03
@NathanFlurry NathanFlurry force-pushed the graphite-base/4896 branch from 7cff899 to 5ffa0d0 Compare May 3, 2026 21:03
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4896 to driver-test-complaints/stub-preload-hints May 4, 2026 04:02
@NathanFlurry NathanFlurry changed the base branch from driver-test-complaints/stub-preload-hints to graphite-base/4896 May 4, 2026 04:03
@NathanFlurry NathanFlurry force-pushed the graphite-base/4896 branch from 7cff899 to 5ffa0d0 Compare May 4, 2026 04:03
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4896 to 05-02-chore_driver-test-runner_add_native_wasm_runtime_matrix_to_skill May 4, 2026 04:03
This was referenced May 4, 2026
Base automatically changed from 05-02-chore_driver-test-runner_add_native_wasm_runtime_matrix_to_skill to main May 4, 2026 09:06
@NathanFlurry NathanFlurry merged commit 20f0389 into main May 4, 2026
14 of 55 checks passed
@NathanFlurry NathanFlurry deleted the driver-test-complaints/loosen-serverless-header-test branch May 4, 2026 09:06
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