test(account): regression for object params in the abuse rate-limit hook

Sends an empty JSON object as an extra body param, which decodes to a
stdClass. Before the fix this threw a TypeError in the abuse init hook
before the action ran; the request should return 201 instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk65HXZhw3oTWybzCYHP3G
This commit is contained in:
ArnabChatterjee20kandClaude Opus 4.8 committed 2026-08-25 11:34:08 +05:30
1 parent 4241f5f4cb
commit c355c4d6ff
1 file changed
+25
@@ -139,6 +139,31 @@ trait AccountBase
];
}
/**
* Regression: the abuse hook stringifies every request param into the
* rate-limit key. An empty JSON object in the body decodes to a stdClass,
* which used to be passed straight to the string-only setParam() and threw
* a TypeError before the action ran. The request must succeed instead of
* returning a 500.
*/
public function testCreateAccountWithObjectParam(): void
{
$response = $this->client->call(Client::METHOD_POST, '/account', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => ID::unique(),
'email' => uniqid() . 'objectparam@localhost.test',
'password' => 'password',
'name' => 'User Name',
'metadata' => (object) [], // serializes to `{}`, decoded as stdClass
]);
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
}
public function testEmailOTPSession(): void
{
$isConsoleProject = $this->getProject()['$id'] === 'console';