Skip to content

fix(domain): allow null --attach in domain:add on production env#55

Merged
miguelsanchez-upsun merged 3 commits intomainfrom
fix/domain-add-typeerror
Apr 29, 2026
Merged

fix(domain): allow null --attach in domain:add on production env#55
miguelsanchez-upsun merged 3 commits intomainfrom
fix/domain-add-typeerror

Conversation

@pjcdawkins
Copy link
Copy Markdown
Contributor

Summary

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:

Fatal error: Uncaught TypeError: Platformsh\Cli\Model\EnvironmentDomain::add():
  Argument #4 ($replacementFor) must be of type string, null given

The fix makes $replacementFor nullable. The existing !empty() guard already treats null and '' the same, so the outgoing request body is unchanged.

An integration test runs domain:add against a mocked API and asserts the captured request body carries the domain name without replacement_for. The test was verified to fail with the original TypeError before the fix and pass after.

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>
Copilot AI review requested due to automatic review settings April 29, 2026 08:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 (default null) to match DomainCommandBase::$attach.
  • Add an integration regression test that runs domain:add against 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.

Comment thread integration-tests/domain_add_test.go Outdated
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 miguelsanchez-upsun merged commit 5dc6187 into main Apr 29, 2026
4 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.

3 participants