Skip to content

Cache misbehaves on version 1.3.4  #1009

Description

@jneisener

Description of the bug

We have simulations with and without header matchers. We noticed that on version 1.3.4 we get wrong results back from Hoverfly on requests that do not contain header matchers.

Steps to reproduce the issue

Difficult to describe in detail, but feel free to reach out I can demonstrate in a call (or expand the description here).

I'll try to illustrate, cannot share the entire recordings.
Request 1:

{
				"request": {
					"path": [
						{
							"matcher": "exact",
							"value": "/s4hanacloud/sap/opu/odata/sap/API_OUTBOUND_DELIVERY_SRV/$metadata"
						}
					],
					"method": [
						{
							"matcher": "exact",
							"value": "GET"
						}
					],
					"destination": [
						{
							"matcher": "exact",
							"value": "sandbox.api.sap.com"
						}
					],
					"scheme": [
						{
							"matcher": "exact",
							"value": "https"
						}
					],
					"body": [
						{
							"matcher": "exact",
							"value": ""
						}
					],
					"query": {
						"sap-documentation": [
							{
								"matcher": "exact",
								"value": "all"
							}
						]
					}
				},
				"response": {
					"status": 200,
					"body": "<Some xml>",
    				"encodedBody": false,
					"headers": {
						"Cache-Control": [
							"max-age=0"
						],
						"Content-Type": [
							"application/xml"
						]
					},
					"templated": false
				}
			},

Request 2:

				"request": {
					"path": [
						{
							"matcher": "exact",
							"value": "/path/to/resource"
						}
					],
					"method": [
						{
							"matcher": "exact",
							"value": "GET"
						}
					],
					"destination": [
						{
							"matcher": "exact",
							"value": "service.tld"
						}
					],
					"scheme": [
						{
							"matcher": "exact",
							"value": "https"
						}
					],
					"headers": {
						"SpecificHeader": [
							{
								"matcher": "exact",
								"value": "Specific-Value"
							}
						]
					}
				},
				"response": {
					"status": 200,
					"body": "<Some json>",
					"encodedBody": false,
					"headers": {
						"Content-Length": [
							"..."
						],
						"Content-Type": [
							"application/json"
						]
					},
					"templated": false
				}
			},

Observed result

Requests (with Hoverfly as proxy):

  • GET https://service.tld/path/to/resource (with correct header)
    • Returns <Some json> (correct result)
  • GET https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_OUTBOUND_DELIVERY_SRV/$metadata?sap-documentation=all
    • Returns <Some json> (incorrect result)
  • GET https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_OUTBOUND_DELIVERY_SRV/$metadata (missing query)
    • No match found (correct result)

To me it looks like the lookup is done correctly (result is only returned on requests that exist in the simulation) but the returned result does not come from the cache if it matched, instead one of the simulations with a header matcher is returned (it seems to always be the same one).

Best guess: Related to #1006

Expected result

  • GET https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_OUTBOUND_DELIVERY_SRV/$metadata?sap-documentation=all
    • Returns <Some xml>

Additional relevant information

  1. Hoverfly version: v1.3.4
  2. Anything that might help us to diagnose the problem: does not happen on v1.3.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions