👟 Reproduction steps
Since appwrite: 26.0.0, Execution.fromMap (in lib/src/models/execution.dart) parses the resourceType field like this:
resourceType: enums.ExecutionResourceType.values.firstWhere(
(e) => e.value == map['resourceType'],
),
This throws Bad state: No element on any self-hosted Appwrite server that predates the Functions/Sites unification and therefore doesn't send a resourceType field in the execution response — it still returns the older shape with functionId instead of resourceId/resourceType.
Because firstWhere has no orElse, this crashes on every Functions.createExecution() / Functions.getExecution() / Functions.listExecutions() call against such a server, even though the HTTP call itself succeeds (2xx) and the function executes correctly — the data is simply lost because the SDK can't build the Execution model from a valid response.
To Reproduce
- Point the SDK at a self-hosted Appwrite server running a version prior to the Functions/Sites unification (i.e. one that still returns functionId on executions instead of resourceId + resourceType).
- Call Functions.createExecution(...).
- The function executes successfully server-side, but the SDK throws:
Bad state: No element
#0 ListBase.firstWhere (dart:collection/list.dart:132:5)
#1 new Execution.fromMap (package:appwrite/src/models/execution.dart:92:56)
#2 Functions.createExecution (package:appwrite/services/functions.dart:81:29)
Raw response for such an execution (obtained via the REST API directly) looks like:
{
"$id": "...",
"functionId": "test-function-id",
"trigger": "http",
"status": "completed",
"responseStatusCode": 200,
"responseBody": "...",
...
}
Note the absence of resourceId / resourceType.
👍 Expected behavior
The SDK shouldn't hard-crash when the server predates a schema change. At minimum, resourceType should fall back to a sane default (e.g. functions, inferred from the presence of the legacy functionId field) instead of throwing, so callers can still get responseBody/status/etc. Ideally the SDK would also surface a clear version-mismatch error rather than an opaque Bad state: No element.
👎 Actual Behavior
It throw an error
🎲 Appwrite version
Appwrite Cloud
💻 Operating system
Linux
🧱 Your Environment
- appwrite (Dart/Flutter SDK): 26.0.0
- Platform: Flutter, iOS/Android
- Server: self-hosted Appwrite (pre-Sites-unification version)
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?
👟 Reproduction steps
Since
appwrite: 26.0.0,Execution.fromMap(inlib/src/models/execution.dart) parses the resourceType field like this:This throws Bad state: No element on any self-hosted Appwrite server that predates the Functions/Sites unification and therefore doesn't send a resourceType field in the execution response — it still returns the older shape with functionId instead of resourceId/resourceType.
Because firstWhere has no orElse, this crashes on every Functions.createExecution() / Functions.getExecution() / Functions.listExecutions() call against such a server, even though the HTTP call itself succeeds (2xx) and the function executes correctly — the data is simply lost because the SDK can't build the Execution model from a valid response.
To Reproduce
Raw response for such an execution (obtained via the REST API directly) looks like:
{
"$id": "...",
"functionId": "test-function-id",
"trigger": "http",
"status": "completed",
"responseStatusCode": 200,
"responseBody": "...",
...
}
Note the absence of resourceId / resourceType.
👍 Expected behavior
The SDK shouldn't hard-crash when the server predates a schema change. At minimum, resourceType should fall back to a sane default (e.g. functions, inferred from the presence of the legacy functionId field) instead of throwing, so callers can still get responseBody/status/etc. Ideally the SDK would also surface a clear version-mismatch error rather than an opaque Bad state: No element.
👎 Actual Behavior
It throw an error
🎲 Appwrite version
Appwrite Cloud
💻 Operating system
Linux
🧱 Your Environment
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?