fix(intercept): toServeStub silently drops behaviors, _rift, binary mode, and extra header values - #208
Merged
Conversation
…iver (#207) `InterceptImpl.toServeStub` projected an `IsSpec` down to the engine's intercept serve action and silently discarded everything that action cannot carry: behaviors (wait/decorate/repeat/copy/lookup/shellTransform), the `_rift` extensions (templated/script and latency/error/tcp faults), binary body mode, and the 2nd+ values of a multi-valued header. Registration returned success, so a fault-injection test stayed green while asserting against a plain 200 the author never asked for. The engine cannot carry them: `ServeStub` in `intercept_rules.rs` is exactly `{statusCode, headers: HashMap<String,String>, body}` and its deserializer has no `deny_unknown_fields`, so posting the extra fields would be accepted and ignored just as quietly. Carrying them through is an engine change, not an SDK one, so this rejects instead. `requireDeliverable` collects every offending construct in one pass and throws a single `InvalidDefinition` naming all of them and pointing at `redirectTo(imposter)`, which reaches a real imposter and has full stub fidelity. It runs before the rule reaches the transport, so a rejected rule is never registered, and both entry points (`Intercept.serve` and `InterceptRuleBuilder.serve`) share the one guard site. The accepted set's wire output is unchanged. `InvalidDefinition` is widened to cover an SDK-side rejection as well as the engine's HTTP 400; the sealed leaf set is untouched, so the cross-SDK contract holds. rift-scala took the same client-side approach in achird-labs/rift-scala#147. A reflection canary pins the record components of the model types the guard enumerates, so adding a field there fails the build instead of silently reopening this bug. Closes #207
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
InterceptImpl.toServeStubwas silently discarding serve responses that the engine's action cannot deliver: behaviors (wait/decorate/repeat/copy/lookup/shellTransform), the_riftextensions (templated/script and latency/error/tcp faults), binary body mode, and the 2nd+ values of a multi-valued header. Registration returned success, so a fault-injection test stayed green while asserting against the plain 200 the author never asked for.Rather than carrying these through (which requires an engine change), this change rejects them at registration time with a single
InvalidDefinitionerror listing all offending constructs and pointing toredirectTo(imposter)as the correct path for full stub fidelity.InvalidDefinitionis widened to cover SDK-side rejection as well as the engine's HTTP 400; the sealed leaf set is untouched, so the cross-SDK contract holds. rift-scala took the same approach in achird-labs/rift-scala#147.A reflection canary pins the record components of the model types the guard enumerates, so adding a field there fails the build instead of silently reopening this bug.
Verification
./mvnw -o verify -DskipITs— BUILD SUCCESS with 518 core testsjavadoc:javadoc— cleandocs/intercept.mdupdated with the deliverable setCloses #207