Skip to content

fix: make variableId optional in createProjectVariable endpoint - #11795

Merged
ChiragAgg5k merged 5 commits into
appwrite:1.9.xfrom
rathi-yash:fix-11765-global-variable-creation
Apr 9, 2026
Merged

ChiragAgg5k merged 5 commits into
appwrite:1.9.xfrom
rathi-yash:fix-11765-global-variable-creation

Conversation

@rathi-yash

@rathi-yash rathi-yash commented Apr 5, 2026 •

Copy link
Copy Markdown

What does this PR do?

Fixes a bug where creating a global variable (Settings > Global variables) always fails with "Param 'variableId' is not optional".
The createProjectVariable endpoint defined variableId as a required param, but the Console UI does not send it. Other similar endpoints (createVariable for Functions and Sites) generate the ID internally using ID::unique().
This fix makes variableId optional with a default of 'unique()', which the action already handles on line 76. This matches the behavior of the Functions and Sites variable endpoints.

Test Plan

  1. Run Appwrite locally via docker compose
  2. Log in to the Console at http://localhost/console
  3. Go to Settings > Global variables
  4. Click "Create variable", fill in a key and value, and click Create
  5. Variable is created successfully (previously failed with "Param 'variableId' is not optional")

Related PRs and Issues

Fixes #11765

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?

@greptile-apps

greptile-apps Bot commented Apr 5, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where the Console UI's "Create Global Variable" flow always failed because the createProjectVariable endpoint required variableId, but the UI never sends it. The fix makes variableId optional with a default of 'unique()', matching the existing behavior of the analogous Functions and Sites variable endpoints — the action code that handles this case (line 75) was already in place.

Confidence Score: 5/5

Safe to merge — minimal, correct fix with a dedicated new test case.

The change is a one-line param-signature update; the ID-generation logic was already handled correctly. A new E2E test case explicitly covers the omitted-ID path. No P0/P1 findings.

No files require special attention.

Vulnerabilities

No security concerns identified. Making variableId optional does not introduce any auth bypass or injection risk; input is validated by the existing CustomId validator before use.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Modules/Project/Http/Project/Variables/Create.php Makes variableId optional (default 'unique()') to match Console UI behavior; action already handled the unique() substitution on line 75, so this is a minimal, correct fix.
tests/e2e/Services/Projects/ProjectsConsoleClientTest.php Adds a test case that omits variableId and asserts a 201 with an auto-generated $id; also adds x-appwrite-response-format: 1.8.0 headers and updates platform type assertions from merge-in 1.9.x changes.

Reviews (5): Last reviewed commit: "Merge branch '1.9.x' into fix-11765-glob..." | Re-trigger Greptile

@ChiragAgg5k ChiragAgg5k left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. lets remove any formatting changes unrelated to the fix
  2. add a test case where we dont pass in variableId and verify it suceeds

@rathi-yash
rathi-yash requested a review from ChiragAgg5k April 8, 2026 19:18
@rathi-yash

rathi-yash commented Apr 8, 2026 •

Copy link
Copy Markdown
Author

I created a new testcase where we are omitting passing the VariableId and it is succeeding.
image

@ChiragAgg5k
ChiragAgg5k merged commit 597b20a into appwrite:1.9.x Apr 9, 2026
15 of 16 checks passed
ChiragAgg5k added a commit that referenced this pull request Apr 9, 2026
…riable-creation"

This reverts commit 597b20a, reversing
changes made to 20f80ac.
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.

Global variables not working in 1.9.0 local

2 participants