Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1153 +/- ##
=======================================
Coverage 95.55% 95.55%
=======================================
Files 61 61
Lines 6004 6077 +73
=======================================
+ Hits 5737 5807 +70
- Misses 267 270 +3
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:
|
While working on better support for calling Standby Actors from the API client (apify/apify-client-python#1153), I couldn't find an explanation of how the authentication headers are handled (Maybe I just missed it?). I have two questions: 1. Does the Apify token reach the Actor's code? (It shouldn't.). 2. If an Actor needs its own authentication header, what's the best practice for sending it? Is it `X-Apify-Authorization`? I drafted a change; see the diff and suggest better/correct/more precise explanation. Thank you. (tagging @mvolfik, as I know a lot of the work there was done by you)
standby_request for calling Standby Actorsstandby_request for calling Standby Actors, with per-request compression in HTTP clients
standby_request for calling Standby Actors, with per-request compression in HTTP clientsserver_request for calling Server Actors, with per-request compression in HTTP clients
server_request for calling Server Actors, with per-request compression in HTTP clientsserver_request for calling Server Actors endpoints
server_request for calling Server Actors endpointsserver_request for calling Server Actor endpoints
|
|
||
| return True | ||
|
|
||
| async def server_request( |
There was a problem hiding this comment.
I'm not sure about the name server_request 😄, but couldn't come up with anything better... Happy to hear your ideas.
There was a problem hiding this comment.
I am still not sure about the ideal way to support server actors. Those can be of very different categories:
- Full app for browser
- Simple one endpoint API
- Complex API with many endpoints and full OpenAPI specification
- ...?
I think this change fits very well the 2. usecase, while its utility drops for the others.
What will be the natural way to work with usecase 3? I guess it could be actually generating that actor-server specific API client and using that. The only thing needed for that is the proper URL
So as mentioned in the Slack discussion in the issue description, I would probably also add these 2 methods:
get_server_actor_urlas a generally useful method (just a visible alias to fetch something from configuration and double checking it is really a server actor)get_server_actor_openapi_specto properly support 3
|
open api specs need apify/apify-docs#3115 |
The build stores the whole `actor.json` as `actorDefinition`, and `GET
/actor-builds/{buildId}` returns it in full, but the schema only
described part of it. This adds the missing fields: `title`,
`description`, `meta`, `output`, `storages.datasets`,
`storages.keyValueStore`, `webServerSchema`, and `webServerMcpPath`.
`meta` lives in its own `ActorDefinitionMeta` schema so generated
clients get a named model for it.
The Python client needs `webServerSchema` to read a Server Actor's
OpenAPI spec (apify/apify-client-python#1153). I checked the generated
Python models against this spec, and the client's type check and unit
tests pass.
*✍️ Drafted by Claude Code*
server_request for calling Server Actor endpoints
Adds three methods to
ActorClientandActorClientAsyncfor working with Server Actors:server_request()sends an HTTP request to the Actor's server without looking up its URL or attaching the token by hand.get_server_url()returns the server URL (the Actor'sstandbyUrl), for calling the server with another HTTP client.get_server_openapi_spec()returns the server's OpenAPI specification (the web server schema from the Actor's definition), for generating such a client.server_requestfollows the CLI RFC (apify/apify-cli#1299):standbyUrl, and the token goes in theAuthorizationheader, which the platform strips before forwarding.compressionopts in. The timeout defaults tolongto cover a cold start.ApifyApiError, and 5xx/429 are retried like API calls.get_server_openapi_specreads the spec from the build the Actor runs in Server mode:actorStandby.build(a tag or a build number), orlatestif none is set. It returnsNonewhen the build has no web server schema. The schema field comes from apify/apify-docs#3115.To support compression per request,
HttpClient.callandHttpClientAsync.calltake a newcompressionargument. A custom HTTP client that overridescallmust accept it.Also fixes the docstring sync script turning
ApifyClientErrorinto a nonexistentApifyClientAsyncError, and adds a Server Actors concepts page.Closes: #973
✍️ Drafted by Claude Code