Skip to content
Back

Local Serverless Function Testing: Are Dynamic API keys supported?

  • 0
  • Functions
  • Cloud
Godonan
27 Apr, 2026, 01:04

I have followed the instructions to get the CLI working, and have been able to log-in, initialize my project, and created a simple Python function, which calls Health(). I can execute appwrite run function, spin up the docker container, and get everything built.

The problem is that at the start before environment preparation, I get a warning: Warning: Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: Not Found

I am wondering if this is leading to a secondary error, as when I attempt to open the resulting localhost:3000 website, I get the following error: User (role: guests) missing scopes (["health.read"])

In my appwrite.config.json file I have "guests" added to the execute, and all health.read added to scopes.

I am able to push the function, deploy, activate, and execute in my Console. I can also see, following the push, that the Guests is in the Role list, and the health.read is a selected scope.

If it matters, I also get this warning right after the success and url printout: /usr/local/server/src/function/runtime-env/lib/python3.14/site-packages/aiohttp/web_protocol.py:627: SyntaxWarning: 'break' in a 'finally' block break

Printing the x-appwrite-key gets an empty string.

My appwrite version is 19.0.0

My code is below:

TypeScript
from appwrite.client import Client
from appwrite.services.health import Health

import os

def main(context):
    try:
        client = (
            Client()
            .set_endpoint(os.environ["APPWRITE_FUNCTION_API_ENDPOINT"])
            .set_project(os.environ["APPWRITE_FUNCTION_PROJECT_ID"])
            .set_key(context.req.headers.get("x-appwrite-key"))
        )
    
        Health(client).get()
        return context.res.json({"status": "ok"})
    except Exception as e:
        context.error(str(e))
        return context.res.json({"status": "error", "message": "Internal server error"}, 500)
TL;DR
Developers encountered a warning that Dynamic API key was not generated while testing a local serverless function using Appwrite CLI. This led to an error about missing scopes when trying to access localhost. The fix was to add the missing scopes for the guest role in the appwrite.config.json file. Additionally, there was a warning about a 'break' in a 'finally' block. The issue was resolved by ensuring the x-appwrite-key had a value.
Godonan
27 Apr, 2026, 01:09

CLI output:

TypeScript
  runtime     │ entrypoint  │ path                     │ commands                        │ scopes      
 ─────────────┼─────────────┼──────────────────────────┼─────────────────────────────────┼──────────── 
  python-3.14 │ src/main.py │ functions/so-healthcheck │ pip install -r requirements.txt │ [54 items]  
                                                                                                       
Hint: If you wish to change your local settings, update the appwrite.config.json file and rerun the 'appwrite run' command.
Hint: Permissions, events, CRON and timeouts don't apply when running locally.
ℹ Warning: Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: Not Found
ℹ Info: Verifying Docker image ...
ℹ Info: Building function using Docker ...
Godonan
27 Apr, 2026, 01:10
TypeScript
>> After env prep, package installations, and starting function in docker:

[00:56:36] [open-runtimes] Runtime started. 
HTTP server successfully started!

Success: Visit http://localhost:3000/ to execute your function.

/usr/local/server/src/function/runtime-env/lib/python3.14/site-packages/aiohttp/web_protocol.py:627: SyntaxWarning: 'break' in a 'finally' block
  break
Info: Runtime logs: >> Here I open the localhost link

User (role: guests) missing scopes (["health.read"])
User (role: guests) missing scopes (["health.read"])
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more