Repository navigation
Conversation
…refresh it on redeploy Nothing in 2.0 writes providerRootDirectory onto VCS deployments (only the template flow does), so Duplicate/Create clones a NULL and the VCS clone turns an empty root directory into a * sparse checkout - the build runs at the repository root and monorepo functions fail. The same missing write empties APPWRITE_VCS_ROOT_DIRECTORY at runtime. Duplicate now refreshes providerRootDirectory from the function like entrypoint/buildCommands/startCommand (also healing legacy NULL deployments on the next redeploy), and Deployments::submit snapshots the source subdir onto new VCS deployments. Upload flow (submit(null)) untouched.
|
| // before this attribute was persisted carry NULL, which the VCS | ||
| // clone path turns into a '*' wildcard - the build then runs at | ||
| // the repository root and monorepo functions fail. | ||
| 'providerRootDirectory' => $function->getAttribute('providerRootDirectory', ''), |
There was a problem hiding this comment.
Template root gets overwritten
When duplicating a public-template deployment, this replaces the deployment-specific source root with the function's root directory. Template deployments store their own root, which can differ from or be absent on the function. In that case, the duplicate fetches the repository root instead of the template subdirectory, so the build uses the wrong source. Preserve the deployment root for public templates and refresh it from the function only for connected VCS deployments.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php
Line: 143
Comment:
**Template root gets overwritten**
When duplicating a public-template deployment, this replaces the deployment-specific source root with the function's root directory. Template deployments store their own root, which can differ from or be absent on the function. In that case, the duplicate fetches the repository root instead of the template subdirectory, so the build uses the wrong source. Preserve the deployment root for public templates and refresh it from the function only for connected VCS deployments.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
Closing as superseded - fixed upstream in #13622 and utopia-php/monorepo#260. @ChiragAgg5k's change covers this ground, so this branch is no longer needed. |
Fixes #13587.
Root cause (the reporter's, confirmed at HEAD)
@AlimFreight traced this end to end; verified independently here:
Deployments/Duplicate/Create.phprefreshesentrypoint/buildCommands/startCommandfrom the function on redeploy but inheritsproviderRootDirectoryfrom the old deployment.providerRootDirectoryonto VCS deployments - only the template flow (Deployments/Template/Create.php:184) does - so the duplicate gets NULL.utopia-php/vcs(Adapter/Git/GitHub.php,generateCloneCommand): an empty root directory becomes a*sparse checkout, so the whole repo is checked out, the build runs at the repository root, and monorepo function code is missing - the ~1s build failure in the reporter's log.APPWRITE_VCS_ROOT_DIRECTORYat runtime (Executions/Create.phpand the build env inDeployments.php:715read it from the deployment).Fix (2 files, +13)
providerRootDirectoryfrom the function, same treatment asentrypoint/commandsabove it. A redeploy rebuilds with the function's current root directory - and because it overwrites the inherited NULL, this also heals every existing broken deployment on its next redeploy, no backfill needed (which matches the reporter's finding that backfilling wasn't a path forward).submit(): snapshot$source['subdir']asproviderRootDirectoryon new VCS deployments so the value persists going forward. The upload flow (submit(null)) is untouched.Verification
Every step of the chain re-traced in source at
main(f31509d), including the'*'wildcard in the vcs library and all read sites. Not run: no PHP runtime or live Appwrite instance in the author's environment, so no lint or live redeploy test - the reporter offered to test a Redeploy on a subdirectory function, which would be the real-world green proof. (TheirPOST /deployments/vcsworkaround is correct until this lands.)