Skip to content

refactor: omit the project name in WriteConfig's copy, not in app.Name (#9029) [skip ci] - #9029

Merged
rfay merged 1 commit into
ddev:mainfrom
rfay:20261028_rfay_writeconfig_omit_name
Nov 2, 2026
Merged

rfay merged 1 commit into
ddev:mainfrom
rfay:20261028_rfay_writeconfig_omit_name

Conversation

@rfay

@rfay rfay commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

With omit_project_name_by_default, ddev config no longer blanks app.Name to keep the name out of config.yaml. WriteConfig leaves it out of its own copy instead, so the project is always registered under its real name.

The Issue

Both ddev config paths set app.Name = "", called WriteConfig, then restored the name. While the name was empty, WriteConfig registered the project under "", which caused #9017. #9020 refuses the empty name and registers the real one afterward. This PR removes the empty name at its source.

How This PR Solves The Issue

  • New DdevApp.WriteConfigOmittingName clears name only on the copy that WriteConfig marshals. This is the same way WriteConfig already drops defaults like project_tld and a name set by config.*.yaml.
  • Both ddev config paths call it instead of clearing and restoring app.Name. Each path keeps its current rule for when to omit the name.
  • UpdateGlobalProjectList no longer skips an empty name, so an empty name now fails with the error from fix: lock and reread project_list.yaml on every change, never register an empty project name, fixes #9004, fixes #9017 #9020.
  • One visible change: with omit_project_name_by_default, ddev config now populates .ddev/commands, examples and homeadditions right away, as it does without the setting. Before, PopulateExamplesCommandsHomeadditions got the blanked name and returned early, so they appeared only on ddev start. The Composer v1 warning also names the project instead of printing ''.

Manual Testing Instructions

ddev utility download-ddev --pr 9029
export PATH="$HOME/tmp/ddev-download-ddev/pr-9029:$PATH"
ddev config global --omit-project-name-by-default=true
mkdir ~/tmp/omitproj && cd ~/tmp/omitproj
ddev config          # accept the defaults
grep '^name:' .ddev/config.yaml   # expect no output
grep -A1 '^omitproj:' ~/.ddev/project_list.yaml   # expect approot: .../omitproj
grep '^"":' ~/.ddev/project_list.yaml   # expect no output
ddev config --php-version=8.4   # flag path; repeat the three greps
ddev config global --omit-project-name-by-default=false

Automated Testing Overview

TestOmitProjectNameByDefault now also checks that each case registers the project under its runtime name with the right approot, and never under "".

🤖 Developed with assistance from Claude Code

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Download this PR's build for your OS and architecture with:

ddev utility download-ddev --pr 9029

Or download the artifact for your OS and architecture directly:

See Testing a PR.

Open in GitHub Codespaces

@rfay
rfay marked this pull request as ready for review October 31, 2026 01:45
@rfay
rfay requested a review from a team as a code owner October 31, 2026 01:45
With omit_project_name_by_default, both `ddev config` paths cleared
app.Name, called WriteConfig, then restored it. While it was empty,
WriteConfig registered the project under "". WriteConfigOmittingName
clears the name only on the copy it marshals, as WriteConfig already
does for defaults, so app.Name stays real throughout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@stasadev stasadev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works, approving. Two small things, neither blocks merge.

Claude Code compared the PR build with main at e907890, with omit_project_name_by_default: true. It ran ddev config interactively, with flags, with --auto, with --project-name, with an interactive custom name, and with a name in config.local.yaml. Both builds wrote the same name and registered the same projects in project_list.yaml, and no "" entry appeared.

  1. One behavior change isn't in the description. writeConfig now passes the real name to PopulateExamplesCommandsHomeadditions(), which returned early for "". So with the omit setting, ddev config now fills .ddev/commands, examples and homeadditions right away, the same as without it. Before, they appeared only on ddev start. That's an improvement, maybe add a line about it.
  2. The two call sites choose the writer in different ways: if omitName { ... } else { ... } in runConfig and writeConfig := app.WriteConfig in handleMainConfigArgs. Maybe use the same pattern in both?

The flag path still drops a custom name whenever --project-name isn't given, which this PR keeps on purpose. On v1.25.5 that already breaks ddev restart and leaves the project on an empty database, see #9047.

🤖 Reviewed with assistance from Claude Code

@rfay rfay changed the title refactor: omit the project name in WriteConfig's copy, not in app.Name refactor: omit the project name in WriteConfig's copy, not in app.Name (#9029) [skip ci] Nov 2, 2026
@rfay
rfay merged commit 1d2028d into ddev:main Nov 2, 2026
51 of 52 checks passed
@rfay
rfay deleted the 20261028_rfay_writeconfig_omit_name branch November 2, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants