Repository navigation
fix: Imposter.delete() of an absent imposter succeeds over HTTP but throws embedded (rift#1371) - #318
Merged
Conversation
rift 0.22.0 answers DELETE /imposters/:port for an absent port with 200 {}
(rift#1371, Mountebank's teardown), while rift_delete_imposter still returns
-1, so the same call succeeded remotely and threw embedded. Deleting an
absent imposter is now a no-op everywhere: remote also accepts the 404 older
engines send, and embedded probes rift_get_imposter after a -1, so a delete
that leaves the imposter registered still throws.
Closes #308
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.
Deleting a port that has no imposter now behaves the same on both transports: it is a no-op, as in Mountebank and rift#1371.
200 {})404)ImposterNotFoundrift_delete_imposter→-1)EngineErrorA delete that fails and leaves the imposter in place still throws
EngineError. So does a remote response that is neither 2xx nor 404.Changes
RemoteTransport.deleteImpostertreats a 2xx or a 404 as success. Every other status goes throughmapError. The class javadoc documents the 404 exception.FfiCalls.deleteImposter: on-1it captures the engine error first, because the probe clearslast_error. It then callsrift_get_imposter. If the imposter is gone, the delete is a no-op; if it is still registered, the captured error is thrown. A failed engine delete always leaves the imposter registered (manager.rsremoves it from the map last). The JDK 21 variant shares these sources.Imposter.delete()(which had none) andRiftTransport.deleteImposterstates the contract.docs/design/sdk-api.mdis updated to match.Release note (behaviour change)
Imposter.delete()on an imposter that is already gone now returns normally. Before, it threwImposterNotFound(remote) orEngineError(embedded). To check whether an imposter exists, userift.imposter(port).Tests
RemoteTransportGateTest:deletingAnImposterAnOlderEngine404sIsANoOpreplaces the olddeleteMissingImposterThrowsImposterNotFound. It failed before this change withImposterNotFound.deletingAnAbsentImposterOnA022EngineIsANoOp.aFailedDeleteStillThrows, where a 500 throwsEngineError(500).EmbeddedTransportIT.deletingAnImposterTwiceIsIdempotent: deletes the same imposter twice, then a port that was never created. It failed before withEngineError: rift_delete_imposter: Imposter not found on port 49152.ImposterDeleteIT(conformance, SPAWN and EMBEDDED): create, delete twice, thenrift.imposter(port)is empty.Verification
RIFT_IT=1 ./mvnw -B -fae verifypasses on JDK 21 against the rift 0.22.0 corpus, dylib and binary.ImposterDeleteITalso passes withCONFORMANCE_TRANSPORT=EMBEDDED.Closes #308
🤖 Generated with Claude Code