Skip to content

fix: treat explicit null optional params as omitted without changing endpoints that rely on null - #13852

Merged
ChiragAgg5k merged 3 commits into
mainfrom
fix/null-params-keep-behaviour
Sep 23, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
fix/null-params-keep-behaviour

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

This PR moves Appwrite onto the utopia-php/http fix from utopia-php/monorepo#327. That fix treats an explicit null for an optional param as if the param had been omitted, unless the param's validator accepts null.

Today, sending null for an optional param skips validation and passes null to the action. Any action with a typed signature then returns a 500. With the fix, those 500s go away across every endpoint. Examples are push message create ("image": null, seen on Cloud) and site rule create ("branch": null).

A few endpoints currently treat an explicit null as meaningful, usually as "keep the current value". Two independent audits covered every ->param() in src/ and app/controllers/. For each of these endpoints, the validator is now wrapped in Nullable and the default is left unchanged. As a result, an explicit null still reaches the action exactly as it does today, and an omitted param still gets the same default. Nothing about these endpoints changes except that the spec now marks the param as nullable, which reflects what it already accepted.

Endpoint Param Explicit null today (kept) Without the wrap it would become
PUT /v1/sites/:siteId providerRepositoryId keeps the VCS connection '', which disconnects the repository
PUT /v1/storage/buckets/:bucketId maximumFileSize keeps the bucket value the plan limit
PUT /v1/storage/buckets/:bucketId compression keeps the bucket value none
PUT /v1/storage/buckets/:bucketId encryption keeps the bucket value true
PUT /v1/vectorsdb/:databaseId/collections/:collectionId enabled keeps a disabled collection disabled true (re-enabled)
POST /v1/users password 400 password_personal_data when the personal-data policy is on a user with no password (201)
POST /v1/messaging/messages/email attachments stored and returned as null []

Endpoints left unwrapped on purpose, where null is a 500 today and the fix should apply:

  • POST /v1/proxy/rules/site branch: null fails the deployment lookup (Invalid query: Query value is invalid for attribute "providerBranch"). With this PR it behaves like an omitted branch.
  • POST /v1/messaging/messages/push, all optional params: a TypeError on the action signature, or count(null).
  • SMS/email/push topics/users/targets: on non-draft messages these hit count(null) or array_merge(null, …). Drafts already store [] through the messages collection default, so nothing changes there.

Audit totals for params that are optional and have a non-null default:

  • 856 in total.
  • 793 bind to a non-nullable action argument, so today an explicit null is a 500 and this PR fixes it.
  • 56 accept null and either treat it the same as the default or crash on it. The site rule branch and the messaging recipients above are in this group.
  • The 7 in the table above are wrapped.

Before / after

POST /v1/messaging/messages/push
Content-Type: application/json

{"messageId":"unique()","title":"Hello","body":"World","image":null,"draft":true}
// before: HTTP 500
{"message":"Server Error","code":500,"type":"general_unknown","version":"2.2.0"}
// after: HTTP 201, identical to omitting "image"
{"$id":"…","providerType":"push","topics":[],"users":[],"targets":[],"scheduledAt":null,"data":{"title":"Hello","body":"World","priority":"high"},"status":"draft"}
POST /v1/proxy/rules/site
Content-Type: application/json

{"domain":"shop.example.com","siteId":"<SITE_ID>","branch":null}
// before: HTTP 500
{"message":"Server Error","code":500,"type":"general_unknown","version":"2.2.0"}
// after: HTTP 201, same deploymentId and deploymentVcsProviderBranch as omitting "branch"

Unchanged (a wrapped param):

PUT /v1/storage/buckets/<BUCKET_ID>
Content-Type: application/json

{"name":"Uploads","maximumFileSize":null,"compression":null,"encryption":null}
// before and after: HTTP 200, the bucket keeps its maximumFileSize, compression and encryption

Test Plan

New e2e tests:

  • Messaging testCreatePushWithNullOptionalParams: sending every optional param as null gives the same stored message as omitting them. null recipients without draft get the same 400 as omitted ones.
  • Proxy testCreateSiteRuleWithNullBranch: a rule with a null branch matches the rule created with the branch omitted.
  • Storage testUpdateBucketKeepsSettingsOnNull, VectorsDB testUpdateCollectionEnabledFlag (extended), VCSGitea testUpdateSiteKeepsRepositoryOnNull, Project testPasswordPersonalDataPolicyRejectsNullPassword, Messaging testCreateDraftEmailKeepsNullAttachments: each pins today's null behaviour on a wrapped param.

Each test was run against three builds:

Build 500-fix tests (push, site rule) Behaviour tests (5)
main (current utopia-php/http) fail: 500, as today pass: this is today's behaviour
new utopia-php/http, wraps removed pass fail: bucket resets to 30 MB, collection re-enables, site disconnects, null password creates a user, attachments become []
this PR pass pass

Full suites on this PR, run locally:

  • Messaging, Storage, Users and Project policies pass.

  • These failed locally and have not yet been compared against main in the same setup:

    • VectorsDB embeddings tests (2): the embedding service wasn't running.
    • Proxy API/redirect/function/site rule tests (5) and Sites domain/template tests (4): these go through appwrite.test via Traefik, which routed to a different local stack.

    CI runs these suites with the right services.

  • composer lint and PHPStan pass on the changed files.

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

utopia-php/http now treats an explicit null for an optional param as omitted unless the validator accepts null, which ends the 500s from null reaching typed actions. Endpoints that use null to mean keep-the-current-value wrap their validators in Nullable so they keep receiving null.
@greptile-apps

greptile-apps Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The production changes appear safe to merge, although the existing non-blocking concern about the implementation-coupled push-message test remains outstanding.

Fix All in Claude CodeFindings

  1. P2 Test Mirrors Route Configuration ▶
Fix with agent prompt
### Issue 1
tests/e2e/Services/Messaging/MessagingBase.php:2274-2291
This test enumerates every optional push parameter, repeats the recipient and draft parameter set, and compares a hard-coded selection of response fields. That mirrors the route's current parameter and default configuration instead of testing a focused observable contract. It will require test changes whenever parameters or defaults change, even if public behavior remains correct. The repository requires tests to assert observable behavior rather than duplicate source configuration, so this must be addressed before merging. Use focused requests that cover representative scalar-null handling and recipient validation instead.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Updates utopia-php/http to the immutable 2.0.0-rc33 release so explicit null optional parameters are treated as omitted, while adding nullable validators where null must retain its existing meaning.

  • Preserves null-sensitive update behavior for vector collections, email attachments, sites, storage buckets, and user passwords.
  • Adds end-to-end coverage for preserved-null behavior and null-as-omitted behavior.
  • Replaces the temporary development-branch dependency with the published RC release.

Reviews (3) · Last reviewed commit: "chore: require the released utopia-php/h..."

Comment thread composer.json Resolved
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/null-params-keep-behaviour (after).

Metric Before After Change
🚀 Requests/sec 162.95 177.51 🟢 +8.9%
⏱️ Latency P50 105.08 ms 98.36 ms 🟢 -6.4%
⏱️ Latency P95 257.49 ms 227.35 ms 🟢 -11.7%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 98.36 227.35 11,400 177.51 -30.14
Account 197.13 353.54 600 10.04 -27.66
TablesDB 96.11 184.99 6,200 99.14 -4.52
Storage 88.98 184.28 3,000 49.23 -41.38
Functions 137.49 268.84 1,600 26.92 -77.76

Top API waits (after)

API request Max wait (ms)
account.prefs.update 576.27
account.name.update 499.63
tablesdb.rows.update 486.42
tablesdb.rows.get 476.58
tablesdb.rows.increment 445.09

@ChiragAgg5k
ChiragAgg5k merged commit dbf2b02 into main Sep 23, 2026
50 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/null-params-keep-behaviour branch September 23, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants