fix: Fix preLookup check by correctly propagating destination options #1037
+4
−3
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.
Context
This PR fixes a problem with the new PreLookup check. The issue was that the destination options (more precisely, the retrieval strategy) was not used when performing the call to get all destinations. This led to situations where some destinations where not correctly found. To fix this, these options are now propagated to the getAllDestinations call.
Important Note
During investigation of this issue we realised that the caching logic of the
GetOrComputeAllDestinationsCommandclass has a flaw: InGetOrComputeAllDestinationsCommand, cache keys are build from the entireDestinationOptionsobject. These options might very well contain information that is irrelevant for the call to get all destinations. This will lead to (potentially many) unnecessary HTTP calls due to over-eager cache isolation.(This was most-probably also already an issue before the addition of the PreLookup check: When change detection was enabled and
DestinationService.tryGetDestinationwas called, we also invokeGetOrComputeAllDestinationsCommandwhich then uses an unnecessarily struct cache. But in that case the outcome is merely an unnecessary cache-miss, which is probably why we did not notice it before.)Example
Assume there are 2 different destinations, dest1 and dest2, with the same destination options, but the options of dest1 include a custom header that is only relevant for getting this single destination. If we now call
tryGetDestination(dest1, options1)and afterwardstryGetDestination(dest2, options2), the invocation ofgetOrComputeAllDestinationsinpreLookupCheckSuccessfulin the second call will not hit the cache as the cache key build fromoptions2differs from the one fromoptions1.There is a second PR to solve this problem by adapting the caching logic in
GetOrComputeAllDestinationsCommandto only use the relevant retrieval strategy as cache key.