fix(samples): rename self-improving-mastra to self-improving - #657
Merged
Conversation
Every GCP deploy of this sample failed: Error: Invalid value for 'entity.managedZone.name': 'defang-self-improving-mastra-production-tamye7zwgmke4-defang-app' That name is 64 characters; Google Cloud DNS caps managed zone names at 63. Defang builds it as defang-<project>-<stack>-<tenant>-<byoc-domain>, so the budget for a project name is 53 - len(stack) - len(tenant) - len(byoc domain). On the production stack that leaves 20 characters, and "self-improving-mastra" is 21. "self-improving" is 14, which brings the zone name to 57 and still fits if the stack name grows to 16 characters -- the CLI's own advisory limit for project, service, and stack names. The directory and the compose `name:` move together, per CLAUDE.md. The name stays explicit rather than defaulting to the directory, because this sample deploys itself from two places: CI runs from the checkout (project would become the repo name) and the admin publish flow runs `defang compose up` from /workspace inside the dev container (project would become "workspace"). An explicit name keeps all paths pointing at one project. Also updates the deploy-changed-samples skip filter, which matches this sample by name. The README title keeps "Mastra" so the sample stays findable by framework.
The deploy job failed on the rename commit: Running tests for samples: ^self-improving-mastra$ Found 0 samples from a total of 85; 0 matched, 0 excluded failed to run tests : no results found `git diff --name-only` reports a rename under its old path, so the changed-sample list named a directory that no longer exists. The load test then matched nothing and exited 1. Filter the list to directories that are still present. An empty list already takes the "no samples have changed" branch, so a PR that only renames or deletes samples now passes instead of hard-failing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
Every GCP deploy of this sample failed:
That name is 64 characters. Google Cloud DNS caps managed zone names at 63.
Defang builds the zone name as
defang-+ project +-+ stack +-+ tenant +-+ BYOC domain, so the budget for a project name is53 - len(stack) - len(tenant) - len(byoc domain). On theproductionstack with a modern tenant that leaves 20 characters, andself-improving-mastrais 21.Worth noting: the old name
self-updating-mastrawas 20 — it fit with zero margin. The rename in 442cf1a added the one character that broke it.The fix
Rename to
self-improving(14 characters). The zone name becomes 57, and it still fits if the stack name grows to 16 characters, which is the CLI's own advisory limit for project, service, and stack names.Directory and compose
name:move together, perCLAUDE.md.Why the name stays explicit instead of defaulting to the directory
Dropping
name:looks cleaner, but this sample deploys itself from two different working directories:name:/home/runner/work/<repo>/<repo>/workspace(Dockerfile.dev,COPY . .)workspaceagent/src/publish.tsrunsdefang compose upwithcwd: REPO_DIR→paths.tsLIVE_REPO, andLIVE_REPO_DIRis never set. So without an explicit name the self-redeploy would target a different Defang project than the original deploy, leaving orphaned resources. An explicitname:keeps every path pointing at one project.Second commit: a CI bug the rename exposed
The first push failed
deploy_changed_samples:git diff --name-onlyreports a rename under its old path, so the changed-sample list named a directory that no longer exists, and the load test matched nothing and exited 1. This would break any PR that renames or deletes a sample, not just this one.Fixed by filtering the list to directories that still exist. An empty list already takes the existing "no samples have changed" branch, so such a PR now passes instead of hard-failing.
Also in this PR
deploy-changed-samples.yml— the skip filter matches this sample by directory name, so it moves with the rename. Without this the sample would be deployed to staging and fail on the missingTEST_ADMIN_TOKENconfig.README.md— the table row path. Edited by hand rather than regenerated:scripts/generate-samples-list.jswould also add a, sampletag to the other 84 rows, since the committed table predates that tag being added to the sample READMEs. The row is byte-identical to what the generator would emit for it. Happy to fold the wider fix in if you'd rather do it here.compose.dev.yamlproject name, the agent's npm package name, a localStorage key, and the agent's git author email.The README title stays "Self-Improving Mastra Todo" and
Tags:still lists Mastra, so the sample stays findable by framework in the Portal and docs listings.Verified locally
defang compose config(nightly v3.12.4, matching CI) exits 0 and resolvesname: self-improving./scripts/check-sample-files.shproduces an empty checklist across all 85 samplesnpm testinscripts/— 22/22 passself-improving-mastraorself-updatingreferences anywhere in the repoWhat green here does not prove
deploy-changed-samples.ymlskips this sample by name (BYOC-only, over the retired Playground staging quota), so CI never deploys it. The GCP fix still needs a real deploy to confirm — anddfng-dev-portal-testing/self-improving-mastracarries its own copy of the old compose name, so it needs regenerating from the template after merge.Follow-ups, not in this PR
defang.io/workshops/self-improving-softwarelinks tosamples/self-updating-mastra, which has 404'd since the July rename. Lives in defang-mvp, needs its own PR — and should point atself-improvingnow.DefangSamples/sample-self-improving-mastra-templatebecomes orphaned.template-manager.jshas no delete path, so it needs a manual cleanup like last time.hashTrim(name, 63)— so a long name either hard-fails or silently resolves to a different zone than the CD expects. The CLI's 16-character advisories also permit 48 characters against a 33-character budget. Filing separately.sampletag inTags:. Pre-existing, and it may hide the sample from listings that filter on it.Samples Checklist
✅ All good!