#13962·appwrite

Malformed function execution headers return HTTP 500 instead of HTTP 400

Author: Indra55Created Sep 28, 2026Updated Sep 28, 2026
Labelsproduct / databasesproduct / functionsproduct / vcs

Reproduction steps

Use a valid project and an API key with the executions.write scope. Send a raw REST request to POST /v1/functions/{functionId}/executions with:

json
{
  "headers": {
    "X-Test": ["bad"]
  }
}

The response is HTTP 500:

json
{
  "message": "Server Error",
  "code": 500,
  "type": "general_unknown"
}

The API log confirms:

TypeError: strlen(): Argument #1 ($string) must be of type string, array given

As a control, this body also returned HTTP 500, even though the header validator correctly rejects the name:

json
{
  "headers": {
    "bad/name": "value"
  }
}

Expected behavior

Both requests should be rejected with HTTP 400 and a useful invalid-headers message.

Actual Behavior

The route's JSONObject validator accepts the shape of the headers object without checking each value's type. Appwrite\Functions\Validator\Headers::isValid() then calls strlen($val ?? '') on the array value (Headers.php:63) and throws a TypeError.

For an invalid header name, Headers::isValid() returns false, but the route calls (Executions/Create.php:169):

php
throw new Exception($validator->getDescription(), 400);

Appwrite\Extend\Exception expects an error type as its first argument and a message as its second, as the datetime check a few lines above does. Here the description is passed as the type and 400 as the message, so the HTTP code is never set and this path also produces a server error.

Appwrite version

Different version (specify in environment)

Operating system

Linux

Your Environment

Self-hosted local Docker Compose development build from upstream/main. GET /v1/health/version reported 2.3.0. Linux host. I sent the request directly to the local API using a valid project and API key; no Appwrite SDK was used.

Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

Have you read the Code of Conduct?