Skip to content

fix(samples): rename self-improving-mastra to self-improving - #657

Merged
raphaeltm merged 2 commits into
mainfrom
fix/shorten-self-improving-project-name
Aug 13, 2026
Merged

fix(samples): rename self-improving-mastra to self-improving#657
raphaeltm merged 2 commits into
mainfrom
fix/shorten-self-improving-project-name

Conversation

@defang-sam

@defang-sam defang-sam Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

The problem

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 the zone name 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 with a modern tenant that leaves 20 characters, and self-improving-mastra is 21.

Worth noting: the old name self-updating-mastra was 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, per CLAUDE.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:

path working directory project name without name:
GitHub Actions /home/runner/work/<repo>/<repo> the repo name
Admin publish button /workspace (Dockerfile.dev, COPY . .) workspace

agent/src/publish.ts runs defang compose up with cwd: REPO_DIRpaths.ts LIVE_REPO, and LIVE_REPO_DIR is never set. So without an explicit name the self-redeploy would target a different Defang project than the original deploy, leaving orphaned resources. An explicit name: keeps every path pointing at one project.

Second commit: a CI bug the rename exposed

The first push failed deploy_changed_samples:

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, 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 missing TEST_ADMIN_TOKEN config.
  • Root README.md — the table row path. Edited by hand rather than regenerated: scripts/generate-samples-list.js would also add a , sample tag 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.
  • Consistency renames with no behaviour change: compose.dev.yaml project 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 resolves name: self-improving
  • ./scripts/check-sample-files.sh produces an empty checklist across all 85 samples
  • npm test in scripts/ — 22/22 pass
  • The changed-sample filter simulated against this branch, before and after the fix
  • No remaining self-improving-mastra or self-updating references anywhere in the repo

What green here does not prove

deploy-changed-samples.yml skips 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 — and dfng-dev-portal-testing/self-improving-mastra carries its own copy of the old compose name, so it needs regenerating from the template after merge.

Follow-ups, not in this PR

  1. defang.io/workshops/self-improving-software links to samples/self-updating-mastra, which has 404'd since the July rename. Lives in defang-mvp, needs its own PR — and should point at self-improving now.
  2. DefangSamples/sample-self-improving-mastra-template becomes orphaned. template-manager.js has no delete path, so it needs a manual cleanup like last time.
  3. The real bug is in Defang: nothing truncates this zone name in the CLI, while the GCP CD does truncate it via 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.
  4. This sample's README is the only one of 85 without the sample tag in Tags:. Pre-existing, and it may hide the sample from listings that filter on it.

Samples Checklist

✅ All good!

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.
@defang-sam
defang-sam Bot had a problem deploying to deploy-changed-samples August 12, 2026 15:55 Failure
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.
@defang-sam
defang-sam Bot deployed to deploy-changed-samples August 12, 2026 15:59 Active
@raphaeltm
raphaeltm merged commit 7b4b49f into main Aug 13, 2026
8 checks passed
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.

1 participant