Repository navigation
Description
👟 Reproduction steps
- Self-hosted Appwrite
2.0.0, PostgreSQL. Any Git-connected function whoseproviderRootDirectoryis a subfolder of a repository (a monorepo makes this obvious, but any repo shows it). - Push a commit and let the VCS build run.
- Look at the deployment in the Console, or
GET /v1/functions/{id}/deployments.
Observed on a repo with 19 Git-connected functions, each with its own providerRootDirectory:
function root dir sourceSize buildSize
contact-email appwrite-functions/contact-email 4.33 MB 2.49 MB
document-parser appwrite-functions/document-parser 4.33 MB 2.43 MB
motive-sync appwrite-functions/motive-sync 4.33 MB 2.94 MB
ifta-report appwrite-functions/ifta-report 4.33 MB 3.01 MB
arrival-nudger appwrite-functions/arrival-nudger 4.33 MB 2.89 MB
… all 19 … 4.33 MB (varies)
sourceSize is byte-identical across every function, regardless of root directory or how much code the function contains. It equals the size of the whole repository: git ls-files -z | xargs -0 tar czf - on the same commit is 4.46 MB.
The same function deployed manually (a tarball of just that folder) reports sourceSize 0.07 MB, and produces a functionally identical build — 2.86 MB vs 2.89 MB.
👍 Expected behavior
sourceSize should describe that deployment's source — the content under providerRootDirectory that was actually built — as it did in 1.9.x, and as the manual-upload path still does.
👎 Actual behavior
For VCS deployments, sourceSize is the size of the temporary clone directory, which is dominated by .git. git fetch --depth=1 downloads every blob of the commit's tree into the object store; core.sparseCheckout only limits which files are written to the working tree. So the number reflects the repository, not the deployment, and is the same for every function built from that repo.
Two consequences:
1. The Console's total is inflated. totalSize = sourceSize + buildSize, so a deployment showing 7.22 MB is really a 2.89 MB artifact plus 4.33 MB of a clone that was deleted seconds later. Users reasonably read this as their function having doubled in size. It also makes the Git and manual paths incomparable, which is what led us here.
2. It is counted as stored bytes when nothing was stored. sourcePath is NULL for every VCS deployment — no source archive is kept. Yet StatsResources.php reports:
['metric' => METRIC_DEPLOYMENTS_STORAGE, 'value' => (int) $dbForProject->sum('deployments', 'sourceSize'), …]On this instance that is 525 MB of "deployments storage" that does not exist on disk (127 VCS deployments × ~4.2 MB), against 1.9 MB genuinely stored by the 21 manual deployments. On Cloud, this metric would over-report — and if it informs plan limits or billing, over-charge — by roughly the repository size on every Git build.
Builds themselves are correct: sparse checkout works, the right folder is built, and the artifact is right. This is purely the reported size.
🔍 This is a 1.9 → 2.0 regression, with before/after from the same instance
Our previous host still had its pre-upgrade database. Same repository, same functions, same providerRootDirectory values:
| period | version | VCS sourceSize |
source stored (sourcePath set) |
|---|---|---|---|
| Aug 2026 | 1.9.x | 0.09 MB avg (min 0.01, max 0.52) | 19 of 21 |
| Sep 2026 | 2.0.0-rc.2 | 4.19 MB | 0 of 1 |
Per-function on 1.9: dashboard_read 0.08 MB, invoice_admin 0.08 MB, ifta_report 0.10 MB — all Git builds, all in the same range as a manual tarball (0.06 MB).
So 1.9 packaged the sparse checkout as a source archive, stored it, and reported that. 2.0 stopped storing a source archive for VCS builds and began reporting the raw clone instead.
🎯 Where it comes from
src/Appwrite/Platform/Modules/Functions/Workers/Jobs.php — sourceSize arrives as a reported artifact and is written straight through:
// A stat artifact reports the file's byte size as its 'content'.
$size = (int) ($data['content'] ?? 0);
…
'sourceSize' => $size,
'totalSize' => $size + (int) $deployment->getAttribute('buildSize', 0),The clone that gets measured is built by generateCloneCommand in utopia-php/vcs (GitHub.php), which sets core.sparseCheckout and then git pull --depth=1 / git fetch --depth=1 — worktree limited, object store not.
Suggested fixes, cheapest first:
- Exclude
.gitwhen measuring (the samersync -av --exclude '.git'the template path inBuilds.phpalready uses), so the number reflects the checked-out source. - Or measure only
providerRootDirectory. - Or, if nothing is stored for VCS builds, report
sourceSizeas0and keep it out ofMETRIC_DEPLOYMENTS_STORAGE, so the storage metric counts only bytes that exist.
🧱 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 - Go functions (
go-1.26), monorepo, oneproviderRootDirectoryper function - Previous host for the 1.9 comparison: same repo, Appwrite 1.9.x on MariaDB 10.11
📎 Additional information
Happy to supply the full per-deployment table, or to test a patch. Related report from the same instance: #13485.
Activity
AlimFreight commentedon Sep 9, 2026
Cross-reference: while investigating this I hit a second, distinct regression from the same 2.0 VCS-source rework — #13587.
RedeployreadsproviderRootDirectoryfrom the deployment, where nothing in 2.0 ever writes it, so it clones the repo root and every monorepo function fails to redeploy in ~1s.They share a root: 2.0 stopped persisting per-deployment source information (
sourcePathis NULL here, andproviderRootDirectoryis NULL on 94 of 128 VCS deployments), but several code paths still read it back from the deployment.breken-ai commentedon Sep 10, 2026
@AlimFreight Confirmed the whole chain at HEAD, with one sharpening:
Sharpening: it is whole-repo-archive vs subdirectory, not .git - forge archives carry no .git, and the clone path records no sourceSize at all. Your numbers back this (4.33MB reported vs ~4.46MB whole-worktree estimate).
The fix is ready and the PR is being filed: re-pack the extracted, rootDirectory-scoped tree into a plain tar and stat that instead - using only existing orchestrator primitives (Stat rejects directories; Archive packs them), so no orchestrator or SDK changes. That kills the phantom at the source. One semantic change to flag: sourceSize becomes uncompressed subdir bytes instead of compressed whole-repo bytes, and existing rows keep inflated values until the next redeploy. If maintainers prefer a smaller blast radius, gating the three StatsResources sums on sourcePath IS NOT NULL fixes the accounting in one line - but leaves the per-deployment display wrong, so we went with the artifact fix.
Since you have 94 functions affected: a quick storage-total check after a redeploy once this is available would be the real-world confirmation.
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.
breken-ai commentedon Sep 10, 2026
The PR is up: #13614
The extracted tree is re-packed to a plain tar and stat'd, so
sourceSizereflects therootDirectory-scoped code the deployment actually builds - not the whole provider archive.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
Thanks — and the sharpening is correct, my mechanism was wrong. I verified it on our instance:
Builds.php→generateCloneCommand(sparse clone) records nosourceSizeat all, whileDeployments.php→supportsRepositoryArchives()→getRepositoryPresignedUrl(format: 'tarball')is the path we're on, and the Stat artifact on that whole-reposource.tar.gzis whatJobs.phpwrites through. The presence of a populatedsourceSizeon our deployments is itself the tell. A forge tarball carries no.git, so "whole-repo archive vs subdirectory" is the right framing — both explanations happen to predict ~4.3 MB, which is why my numbers held up while the reasoning didn't. I've corrected our internal note accordingly.Happy to run the storage-total check once #13614 is available. Baseline here, so the delta is measurable:
sourcePathNULL on every onesum(sourceSize)across themsourceSizeproviderRootDirectoryThe functions live in
appwrite-functions/<name>, tracked repo ≈ 4.46 MB gzipped, so after the fix I'd expect each function'ssourceSizeto drop to its own subdirectory's uncompressed size — for our largest that's a few hundred KB, not 4.33 MB. Noted that existing rows keep inflated values until rebuilt; we push often enough that the whole set will turn over quickly, so I can report both the per-deployment number and the storage total.One thing worth flagging for whoever reviews the PR: with
sourceSizebecoming uncompressed subdirectory bytes,totalSize = sourceSize + buildSizestops being an apples-to-apples sum (uncompressed source + compressed build). That's still far better than today, just worth a deliberate decision rather than a surprise.breken-ai commentedon Sep 10, 2026
@AlimFreight The byte-identical 4.33 MB across all 19 functions is the cleanest possible confirmation - that number can only be the whole-repo tarball, independent of providerRootDirectory, exactly the mechanism in #13614. And thank you for correcting the record on the clone path; the presigned-tarball framing is what the patch stats.
On the units point - fair flag, and worth a deliberate decision as you say. The sum was already mixed-unit before this change (compressed whole-repo archive + compressed build artifact); what changes is that sourceSize becomes the uncompressed size of the tree the deployment actually builds. That is the honest number for "how much source does this deployment represent", and it makes sourceSize comparable across deployments of the same function, which the compressed-tarball number never was (it moved with unrelated repo churn). Making buildSize uncompressed too would be the consistent alternative, but that is a much larger behavioral change for a separate decision. Stated here so it is deliberate, not silent.
Your baseline table is a great validation setup - the post-fix per-deployment number dropping from 4.33 MB to each subdirectory's real size, plus the storage-total delta, is exactly what the fix should produce.
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.
fix(deployments): scope sourceSize to the extracted tree, not the pro…
HarshMN2345 commentedon Sep 29, 2026
Fixed by #13934, VCS deployments now only measure and store the root directory that gets built. It'll be in the next release.