fix(domain): allow null --attach in domain:add on production env#55
Merged
miguelsanchez-upsun merged 3 commits intomainfrom Apr 29, 2026
Merged
fix(domain): allow null --attach in domain:add on production env#55miguelsanchez-upsun merged 3 commits intomainfrom
miguelsanchez-upsun merged 3 commits intomainfrom
Conversation
EnvironmentDomain::add declared $replacementFor as a non-nullable string with default '', but DomainCommandBase::$attach is ?string defaulting to null. Under strict_types this raised a TypeError at the call site when domain:add was run on a production environment without --attach. Make $replacementFor nullable. The existing !empty() guard already treats null and '' the same, so the request body is unchanged. Add an integration test that runs domain:add against a mocked API and asserts the captured request body contains the domain name without replacement_for. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a strict-types TypeError in the legacy domain:add command when running against a production environment without --attach, by allowing the underlying model method to accept a null replacement domain.
Changes:
- Make
EnvironmentDomain::add()accept?string $replacementFor(defaultnull) to matchDomainCommandBase::$attach. - Add an integration regression test that runs
domain:addagainst a mocked API and inspects the captured create-domain request.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| legacy/src/Model/EnvironmentDomain.php | Updates the domain-create helper signature to accept nullable replacementFor, avoiding strict-types failures when --attach is omitted. |
| integration-tests/domain_add_test.go | Adds a regression integration test covering domain:add on a production environment without --attach. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Decode the captured POST body into map[string]any and assert the replacement_for key is not present. Decoding into a string field collapsed absent, "" and null to the same value, so the previous assertion did not actually verify the regression. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
miguelsanchez-upsun
approved these changes
Apr 29, 2026
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.
Summary
EnvironmentDomain::adddeclared$replacementForas a non-nullable string with default'', butDomainCommandBase::$attachis?stringdefaulting tonull. Understrict_typesthis raised aTypeErrorat the call site whendomain:addwas run on a production environment without--attach:The fix makes
$replacementFornullable. The existing!empty()guard already treats null and''the same, so the outgoing request body is unchanged.An integration test runs
domain:addagainst a mocked API and asserts the captured request body carries the domain name withoutreplacement_for. The test was verified to fail with the originalTypeErrorbefore the fix and pass after.