Repository navigation
Conversation
janbuchar
commented
Nov 9, 2026
- follow up to chore: Add parentRequestId to server().request method apify-client-js#1198
- chore because the Server Actor support PR is unreleased
- behavior documented in docs: explain billing and composing server Actors apify-docs#3035
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1214 +/- ##
=======================================
Coverage 95.73% 95.73%
=======================================
Files 63 63
Lines 6676 6680 +4
=======================================
+ Hits 6391 6395 +4
Misses 285 285
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Pijukatel
left a comment
There was a problem hiding this comment.
Just some small suggestions.
| server_url = self.get_url() | ||
| server_path = path.partition('#')[0].lstrip('/') | ||
| if parent_request_id is not None: | ||
| headers = self._http_client._merge_headers(headers, {'X-Actor-Request-ID': parent_request_id}) # noqa: SLF001 |
There was a problem hiding this comment.
Can we refactor it a little so that we do not need # noqa: SLF001 ? Since we need the method outside, may it is time to make it less private?
| response = await server_client.request( | ||
| '/search', | ||
| params={'q': 'apify'}, | ||
| parent_request_id=request.headers['x-actor-request-id'], |
There was a problem hiding this comment.
There are 2 requests in the snippet. One we are sending and the one we have received and are handling right now. I do not think it is obvious from the snippet. Could you either name it differently (incoming_request.headers or handled_request.headers ...) or add some context around the snippet?
vdusek
left a comment
There was a problem hiding this comment.
Chore - no changelog mention?
| parent_request_id: The `X-Actor-Request-ID` header of the request your Server Actor is handling, sent on | ||
| as the same header so the called Actor charges at that request's pricing tier. |
There was a problem hiding this comment.
The method docstring above and the docs page (line 77) say that headers from headers reach the server as they are. parent_request_id replaces one of them, so I'd say it here (and in the async twin):
| parent_request_id: The `X-Actor-Request-ID` header of the request your Server Actor is handling, sent on | |
| as the same header so the called Actor charges at that request's pricing tier. | |
| parent_request_id: The `X-Actor-Request-ID` header of the request your Server Actor is handling, sent on | |
| as the same header so the called Actor charges at that request's pricing tier. It replaces an | |
| `X-Actor-Request-ID` passed in `headers`. |
✍️ Drafted by Claude Code
|
|
||
| When your multi-tenant Server Actor calls another one while handling a request, pass the incoming `X-Actor-Request-ID` header in `parent_request_id`. The client sends it as the same header, so the called Actor charges at the pricing tier of your incoming request. Use a client created with the run's `APIFY_TOKEN`. For details, see [Compose multi-tenant Server Actors](https://docs.apify.com/platform/actors/development/programming-interface/standby#compose-server-actors). | ||
|
|
||
| ```python |
There was a problem hiding this comment.
Could this go into dedicated test files like all other code examples so ruff and ty can check it?
| assert captured[0].headers['X-Apify-Authorization'] == 'Bearer test' | ||
|
|
||
|
|
||
| def test_request_sends_parent_request_id_header(httpserver: HTTPServer, sync_client: ApifyClient) -> None: |
There was a problem hiding this comment.
Async counterpart of this test?