Repository navigation
fix: treat explicit null optional params as omitted without changing endpoints that rely on null - #13852
Merged
Conversation
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.
Contributor
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
2 tasks done
loks0n
approved these changes
Sep 23, 2026
Closed
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
nullfor an optional param as if the param had been omitted, unless the param's validator acceptsnull.Today, sending
nullfor an optional param skips validation and passesnullto 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
nullas meaningful, usually as "keep the current value". Two independent audits covered every->param()insrc/andapp/controllers/. For each of these endpoints, the validator is now wrapped inNullableand the default is left unchanged. As a result, an explicitnullstill 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.nulltoday (kept)PUT /v1/sites/:siteIdproviderRepositoryId'', which disconnects the repositoryPUT /v1/storage/buckets/:bucketIdmaximumFileSizePUT /v1/storage/buckets/:bucketIdcompressionnonePUT /v1/storage/buckets/:bucketIdencryptiontruePUT /v1/vectorsdb/:databaseId/collections/:collectionIdenabledtrue(re-enabled)POST /v1/userspasswordpassword_personal_datawhen the personal-data policy is onPOST /v1/messaging/messages/emailattachmentsnull[]Endpoints left unwrapped on purpose, where
nullis a 500 today and the fix should apply:POST /v1/proxy/rules/sitebranch:nullfails 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: aTypeErroron the action signature, orcount(null).topics/users/targets: on non-draft messages these hitcount(null)orarray_merge(null, …). Drafts already store[]through themessagescollection default, so nothing changes there.Audit totals for params that are optional and have a non-null default:
nullis a 500 and this PR fixes it.nulland either treat it the same as the default or crash on it. The site rulebranchand the messaging recipients above are in this group.Before / after
// after: HTTP 201, same deploymentId and deploymentVcsProviderBranch as omitting "branch"Unchanged (a wrapped param):
// before and after: HTTP 200, the bucket keeps its maximumFileSize, compression and encryptionTest Plan
New e2e tests:
MessagingtestCreatePushWithNullOptionalParams: sending every optional param asnullgives the same stored message as omitting them.nullrecipients withoutdraftget the same 400 as omitted ones.ProxytestCreateSiteRuleWithNullBranch: a rule with anullbranch matches the rule created with the branch omitted.StoragetestUpdateBucketKeepsSettingsOnNull,VectorsDBtestUpdateCollectionEnabledFlag(extended),VCSGiteatestUpdateSiteKeepsRepositoryOnNull,ProjecttestPasswordPersonalDataPolicyRejectsNullPassword,MessagingtestCreateDraftEmailKeepsNullAttachments: each pins today'snullbehaviour on a wrapped param.Each test was run against three builds:
main(current utopia-php/http)[]Full suites on this PR, run locally:
Messaging,Storage,UsersandProjectpolicies pass.These failed locally and have not yet been compared against
mainin the same setup:VectorsDBembeddings tests (2): the embedding service wasn't running.ProxyAPI/redirect/function/site rule tests (5) andSitesdomain/template tests (4): these go throughappwrite.testvia Traefik, which routed to a different local stack.CI runs these suites with the right services.
composer lintand PHPStan pass on the changed files.Related PRs and Issues
Checklist