Repository navigation
Description
π Reproduction steps
- Self-hosted Appwrite
2.0.0. Connect a function to a Git repository where the function's code lives in a subdirectory, i.e. setproviderRootDirectory(the standard monorepo layout β ours isappwrite-functions/<name>). - Push a commit. The build succeeds. β
- Change any function setting (we added an environment variable). The Console shows "Settings changes are not live yet β You've updated function settings, but they won't take effect until you redeploy." with a Redeploy button.
- Click Redeploy (or
POST /v1/functions/{functionId}/deployments/duplicate). - The build fails after 1 second.
Build log (Go function; the failing line differs per runtime, see below):
[22:53:41] [open-runtimes] Build cache hit.
[22:53:41] [open-runtimes] Environment preparation started.
[22:53:41] [open-runtimes] Build command execution started.
bash: line 1: /usr/local/build/vendor/alimfreight.com/shared/go.mod: No such file or directory
[22:53:41] [open-runtimes] Environment preparation finished.
Build failed with exit code 1.
The path exists in the repository at appwrite-functions/arrival-nudger/vendor/β¦. It is missing from /usr/local/build because the build ran against the repository root instead of the function's root directory.
π Expected behavior
Redeploy rebuilds the same source the original deployment built β from providerRootDirectory β and succeeds exactly as a push-triggered build does.
π Actual behavior
Redeploy clones the repository root, so the build runs in the wrong directory and fails. For a Go function this shows as a missing vendored path; other runtimes would fail on a missing package.json, requirements.txt, entrypoint, etc.
Consequence: on a monorepo, the Redeploy button can never succeed, which also means the "Settings changes are not live yet" banner cannot be cleared by the button the Console offers for exactly that purpose. 20 of our 21 functions are affected (every one whose code is not at the repo root).
π― Root cause
src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php takes the root directory from the deployment:
$github->generateCloneCommand(
β¦
$deployment->getAttribute('providerRootDirectory', ''),
);β¦but nothing in 2.0 writes providerRootDirectory onto a deployment. Grepping the codebase, it is only read (here, and for the APPWRITE_VCS_ROOT_DIRECTORY runtime variable in src/Appwrite/Platform/Workers/Functions.php:676 and src/Appwrite/Deployment/Deployments.php:718), cleared (Deletes.php), or migrated (V19.php). On our instance 94 of 128 VCS deployments have it NULL β every one created since we moved to 2.0.
Push-triggered builds are unaffected because Builds.php reads it from the function:
$rootDirectory = $resource->getAttribute('providerRootDirectory', '');And an empty value is not neutral β generateCloneCommand in utopia-php/vcs (GitHub.php) turns it into a wildcard:
if ($rootDirectory === '' || $rootDirectory === '0') {
$rootDirectory = '*';
}
β¦
'git config core.sparseCheckout true',
"echo {$rootDirectory} >> .git/info/sparse-checkout",* sparse-checks-out the whole repository, so /usr/local/build becomes the repo root.
π¬ Things I verified, to save you time
- Backfilling the field on the source deployment does not help. I set
providerRootDirectory = 'appwrite-functions/arrival-nudger'on the ready deployment and clicked Redeploy again: the duplicate came out withproviderRootDirectory = NULLagain and failed identically. So the duplicate path loses it as well as never having it. POST /v1/functions/{functionId}/deployments/vcs(type=branch, reference=main, activate=true) works: built in 4 s, 2.89 MB, activated, and the function'sliveflag flipped totrue, clearing the banner. That endpoint is the usable workaround β "Create deployment β from Git" rather than "Redeploy".- The failed deployments are harmless to delete; the active deployment id was unchanged by deleting them (2.0 no longer clears it, unlike 1.9.x).
π‘ Suggested fix
In Duplicate/Create.php, fall back to the function's value the way Builds.php already does:
$rootDirectory = $deployment->getAttribute('providerRootDirectory', '')
?: $function->getAttribute('providerRootDirectory', '');Better still, persist providerRootDirectory onto the deployment when it is created from VCS, since two other code paths already expect to read it there (the APPWRITE_VCS_ROOT_DIRECTORY runtime variable is currently empty in every runtime for the same reason).
π§± Your Environment
- Appwrite 2.0.0 self-hosted (Docker Compose), PostgreSQL 18.3 (
appwrite/postgres:0.1.0) - Executor
openruntimes/executor:0.29.0, orchestratorghcr.io/open-runtimes/orchestrator:1.9.2 - Runtime
go-1.26; monorepo, oneproviderRootDirectoryper function, 20 of 21 functions in subdirectories - GitHub App installation, branch
main
π Additional information
Same instance as #13586 (also a 2.0 VCS-source regression, different symptom). Happy to test a patch.
Activity
breken-ai commentedon Sep 10, 2026
@AlimFreight Confirmed your root cause at HEAD - and the second half of it: nothing in 2.0 persists providerRootDirectory onto VCS deployments at all (only the template flow writes it), so Redeploy inherits a NULL, the VCS clone turns empty into a * sparse checkout, and the build runs at the repo root. That same missing write is also why APPWRITE_VCS_ROOT_DIRECTORY is empty in every runtime. Your investigation named every layer of this; the fix implements exactly the shape you sketched: #13589 - (1) Redeploy now refreshes providerRootDirectory from the function like entrypoint and build commands, which also heals existing NULL deployments on their next redeploy, and (2) deployment creation snapshots the source root going forward. Your /deployments/vcs workaround is the right one until it lands. Since you offered: a quick Redeploy test on one of your subdirectory functions once this is available would confirm it.
Built by breken, your AI support engineer - breken.ai finds the bug, proves the fix with unmatched RCA, answers customers in your voice, and keeps your code and support docs clean - this one's on us.
AlimFreight commentedon Sep 10, 2026
That matches what we found, including the part I'd only half-stated: nothing persists
providerRootDirectoryonto VCS deployments in the first place, so it isn't merely that Redeploy reads the wrong source β there is nothing at that source to read. 94 of our 128 VCS deployments have it NULL (the 34 that don't predate our 2.0 cutover). Good catch tyingAPPWRITE_VCS_ROOT_DIRECTORYto the same missing write; that one is silent for us because nothing we run reads it, which is exactly how it would stay unnoticed.The two-part shape in #13589 is the right one β refreshing from the function heals the existing NULL rows on their next redeploy, which matters here because otherwise all 94 would stay broken until each was rebuilt some other way.
Happy to run the Redeploy test once it's available. Our setup is a good case for it: 20 of 21 functions live in
appwrite-functions/<name>, so every one of them currently fails Redeploy in ~1s with the build running at the repo root. I'll confirm on a subdirectory function that (a) Redeploy succeeds, (b) the resulting deployment hasproviderRootDirectorypopulated rather than NULL, and (c) an untouched older deployment gets healed on its own next redeploy.Confirming the workaround for anyone who lands here meanwhile:
POST /v1/functions/{functionId}/deployments/vcswith{"type":"branch","reference":"main","activate":true}builds correctly, because that path reads the root directory from the function. Worth knowing it also clears the "Settings changes are not live yet" banner, which is otherwise unclearable on a monorepo β the button the Console offers for it is the broken one.breken-ai commentedon Sep 10, 2026
@AlimFreight That acceptance test is exactly right - (a) Redeploy succeeds, (b) the new deployment has providerRootDirectory populated, (c) an untouched older deployment heals on its own next redeploy. (c) is the one that matters most for your fleet: the refresh-from-function path in #13589 is what heals all 94 NULL rows without anyone rebuilding them by hand. We will ping here once it lands in a release so you can run it on one of your appwrite-functions/ functions.
Built by breken, your AI support engineer - breken.ai finds the bug, proves the fix with unmatched RCA, answers customers in your voice, and keeps your code and support docs clean - this one's on us.
AlimFreight commentedon Sep 11, 2026
Status update, since #13589 was closed unmerged yesterday and 2.1.0 shipped today without a fix: on the
2.1.0tagDuplicate/Create.phpstill readsproviderRootDirectoryfrom the deployment at both call sites (lines 167 and 179), so Redeploy remains broken for every subdirectory function. ThePOST /deployments/vcsworkaround still works on 2.1.0.The Greptile P1 that closed #13589 is correct, and the code already contains the distinction it asks for β the fix just needs to live on the right side of it. In
Duplicate/Create.phpthe two remote-source paths are split by$installationId:elseif ($installationId !== '')βcreateFromVcs(...)β the connected-VCS branch, where nothing ever persisted the root (onlyTemplate/Create.phpline 184 writes it), so the deployment's value is always empty here;createFromRef(...)β the public-template branch, where the deployment's root is real and must be preserved, exactly as the review said.So the narrower fix is a fallback inside the
createFromVcsbranch only, leaving line 179 untouched:That cannot regress templates, because a template duplicate never enters that branch. It also heals the NULL rows created before any persistence existed (94 of 128 here) on their next redeploy. The second half of #13589 β persisting the root onto connected-VCS deployments at creation, mirroring what
Template/Create.phpalready does at line 184 β is still worth doing so thatAPPWRITE_VCS_ROOT_DIRECTORYstops being empty in runtimes, but the one-line fallback alone fixes the user-facing failure.Offer stands to verify on a real 2.x monorepo (20 of 21 functions in subdirectories) the moment a build is available.