You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/mock-request-matching.md
+27-8Lines changed: 27 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,24 @@
4
4
5
5
How an **incoming proxied request** is matched to a **recorded row** in the local DB for mocks: **hash-based** identity, optional **match rules** that drop hash dimensions, and optional **`compute`** to re-hash stored `raw` when **ignored components** change between record time and the retry path. Custom status codes: **`IGNORE_COMPONENTS = 498`**, **`NOT_FOUND = 499`** ([`custom_response_codes`](../stoobly_agent/app/proxy/constants/custom_response_codes.py)) — not standard HTTP 404/498.
6
6
7
-
### Remote project key and `compute`
7
+
### Endpoint lookup and `compute`
8
8
9
-
When **local** + **remote project key**: **`compute='1'`** is attached only if **`retry`** and non-empty **`ignored_components`** after [`eval_request`](../stoobly_agent/app/proxy/mock/eval_request_service.py) ([`COMPUTE`](../stoobly_agent/config/constants/query_params.py)). That widens the ORM query and runs [`filter_requests_by_hashes`](../stoobly_agent/app/models/factories/resource/local_db/helpers/filter_requests_by_hashes_service.py) so stored **`raw`** is re-hashed with the same ignores as the live request.
9
+
When mocking against **local DB**, [`eval_request`](../stoobly_agent/app/proxy/mock/eval_request_service.py) may attach an `endpoint_promise` from either:
10
+
11
+
- remote project endpoint search via [`search_endpoint`](../stoobly_agent/app/proxy/mock/search_endpoint.py), or
12
+
- OpenAPI endpoint search via [`search_open_api_endpoint`](../stoobly_agent/app/proxy/mock/search_open_api_endpoint.py).
13
+
14
+
If `endpoint_promise` exists, and the request is on **retry** with non-empty ignored components, **`compute='1'`** is attached ([`COMPUTE`](../stoobly_agent/config/constants/query_params.py)). That widens the ORM query and runs [`filter_requests_by_hashes`](../stoobly_agent/app/models/factories/resource/local_db/helpers/filter_requests_by_hashes_service.py) so stored **`raw`** is re-hashed with the same ignores as the live request.
15
+
16
+
### Endpoint cache behavior (remote + OpenAPI)
17
+
18
+
[`endpoint_cache`](../stoobly_agent/app/proxy/mock/endpoint_cache.py) is a singleton used by both search paths. It:
19
+
20
+
- caches parsed OpenAPI specs by normalized absolute path,
21
+
- caches remote endpoint index calls by `(project_id, index_params)`,
22
+
- merges both layers into one endpoint-id map, where **latest merge wins** on ID collisions,
23
+
- returns OpenAPI-derived ignored components from optional/nondeterministic fields (query/header/body/response-header),
24
+
- prefetches remote endpoints from settings when remote mode is enabled.
10
25
11
26
### Hash dimensions
12
27
@@ -22,7 +37,7 @@ When **local** + **remote project key**: **`compute='1'`** is attached only if *
| Local DB lookup, strip columns, not found 498/499 |[`request_adapter.py`](../stoobly_agent/app/models/factories/resource/local_db/request_adapter.py)|
0 commit comments