fix: allow creating project variables without variableId (#11765)#11823
fix: allow creating project variables without variableId (#11765)#11823aakarsh12x wants to merge 1 commit intoappwrite:1.9.xfrom
Conversation
Greptile SummaryThis PR fixes a regression in project (global) variable creation where omitting
Confidence Score: 5/5Safe to merge — the change is a minimal, targeted fix with no logic regressions and only a minor test improvement remaining. Both changed files are straightforward: one parameter is made optional with a sensible default, and a regression test is added. The only remaining finding is a P2 style suggestion (missing No files require special attention.
|
| Filename | Overview |
|---|---|
| src/Appwrite/Platform/Modules/Project/Http/Project/Variables/Create.php | Makes variableId optional with a default of 'unique()', consistent with how the rest of the variable creation endpoints work; logic is sound and the existing unique() → ID::unique() conversion on line 75 handles it correctly. |
| tests/e2e/Services/Projects/ProjectsConsoleClientTest.php | First success case in testCreateProjectVariable now omits variableId to exercise the regression path; existing failure cases still pass 'unique()' explicitly which is fine. Minor: the omit-ID case doesn't assert the returned $id is non-empty. |
Comments Outside Diff (1)
-
tests/e2e/Services/Projects/ProjectsConsoleClientTest.php, line 4752-4755 (link)Missing auto-generated ID assertion
The new regression case that omits
variableIdverifies the HTTP status code and payload fields, but never confirms that the server actually returned a non-empty$id. Since the whole point of the fix is that the server must auto-generate a valid ID, it would be worth asserting that here:
Reviews (1): Last reviewed commit: "fix: allow creating project variables wi..." | Re-trigger Greptile
Summary
This fixes project global variable creation in local 1.9.0 setups when the request omits �ariableId.
What was broken
Creating a global variable from the Console could fail with:
Param "variableId" is not optional.
Root cause
src/Appwrite/Platform/Modules/Project/Http/Project/Variables/Create.php still treated �ariableId as a required request parameter, even though the endpoint already supports unique() IDs internally and older compatibility filters already backfill the same default.
Functions and Sites already generate variable IDs server-side, but Project variables still required the client to send one. That made the project/global variables flow inconsistent and caused the request to fail before the existing unique() handling could run.
Fix
Validation
Fixes #11765