Skip to content

Malformed function execution headers return HTTP 500 instead of HTTP 400 #13962

Closed

Description

@Indra55

👟 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:

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

The response is HTTP 500:

{
  "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:

{
  "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):

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?

Activity

  1. added theissue type on Sep 28, 2026
  2. added
    product / databases
    product / functions
    product / vcs
    on Sep 28, 2026
  3. Indra55 commented on Sep 28, 2026

    @Indra55
    ContributorAuthor

    I'd like to work on this. Plan: add a string/null check in Headers::isValid() and throw GENERAL_ARGUMENT_INVALID from the route, with tests. Could I be assigned?

  4. added 2 commits that reference this issue on Sep 28, 2026
    b2be519
    ec55235
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    product / databasesproduct / functionsproduct / vcs

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions