feat: add X-Permit-Consistent-Update header on facts proxy requests#306
feat: add X-Permit-Consistent-Update header on facts proxy requests#306
Conversation
🔍 Vulnerabilities of
|
| digest | sha256:a98c346e98e124f521b798f53ac2646a685c1cd1c2641ce71ffc9cb468899485 |
| vulnerabilities | |
| platform | linux/amd64 |
| size | 215 MB |
| packages | 253 |
📦 Base Image python:3.10-alpine3.22
| also known as |
|
| digest | sha256:a7b85667f5c4e8db146b494344e4a3826e695185c7260bddab7ec9667a2406e3 |
| vulnerabilities |
Description
Description
Description
Description
Description
Description
Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The backend opal-interface uses this header to skip sending the control-plane delta update back to PDPs, since the PDP already propagates the update via OPAL Server pubsub after a successful facts proxy write. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move the X-Permit-Consistent-Update header injection behind an explicit is_consistent_update kwarg so the fallback proxy route (forward_remaining_requests) does not falsely mark generic passthrough requests as consistent updates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
af90b4f to
74bf9ed
Compare
There was a problem hiding this comment.
Pull request overview
Adds an opt-in request header to facts-service proxy calls made via the “wait-for-local-sync” path, allowing the backend to skip emitting a redundant control-plane delta update when the PDP is already publishing an OPAL pubsub update.
Changes:
- Introduce
CONSISTENT_UPDATE_HEADERand anis_consistent_updatekwarg onFactsClient.build_forward_request()/send_forward_request(), addingX-Permit-Consistent-Update: truewhen enabled. - Set
is_consistent_update=Truefor the consistent-update proxy flow (forward_request_then_wait_for_update). - Add unit tests asserting the header is present when requested and absent by default.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
horizon/facts/client.py |
Adds the consistent-update header constant and gating logic in forwarded request construction/sending. |
horizon/facts/router.py |
Enables the consistent-update header for the wait-for-local-sync proxy flow. |
horizon/tests/test_facts_client.py |
Adds tests covering header inclusion/exclusion behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) -> Response: | ||
| _update_id = update_id or uuid4() | ||
| response = await client.send_forward_request(request, path, query_params=query_params) | ||
| response = await client.send_forward_request(request, path, query_params=query_params, is_consistent_update=True) |
There was a problem hiding this comment.
Setting is_consistent_update=True here will cause the backend (per PR description) to skip the control-plane delta publish for all these proxied writes, even when the local pubsub propagation fails or times out. In this codepath publish_and_wait() can return False (publish failure or wait timeout) and with TimeoutPolicy.IGNORE (the default via config) the request still returns success; after this change there would be no fallback update path, which can leave the PDP stale. Consider gating is_consistent_update behind a stricter policy (e.g., only when timeout_policy==FAIL / when you will fail the request on local propagation failure) or otherwise ensuring a reliable fallback when local publish/wait does not succeed.
| response = await client.send_forward_request(request, path, query_params=query_params, is_consistent_update=True) | |
| is_consistent_update = timeout_policy == TimeoutPolicy.FAIL | |
| response = await client.send_forward_request( | |
| request, | |
| path, | |
| query_params=query_params, | |
| is_consistent_update=is_consistent_update, | |
| ) |
Summary
X-Permit-Consistent-Update: trueheader on facts requests that the PDP proxies throughforward_request_then_wait_for_update(the wait-for-local-sync flow)forward_remaining_requests) does NOT set the header, so generic passthrough requests continue to rely on the standard control-plane delta pathDetails
The header is gated behind a new
is_consistent_update: bool = Falsekwarg onFactsClient.build_forward_requestandFactsClient.send_forward_request. Onlyforward_request_then_wait_for_update(called by the explicit consistent-update routes: users, tenants, role_assignments, resource_instances, relationship_tuples) passesTrue.Paired with backend changes in permit-backend (branch:
omer/per-14392-consistent-updates-duplicated-updates) which:is_consistent_update: Trueinto the DB session's AMQP headersTest plan
FactsClient.build_forward_request:is_consistent_update=True🤖 Generated with Claude Code