Skip to content

fix(tunnel:open): cast remote port to int#91

Merged
pjcdawkins merged 1 commit into
mainfrom
fix/tunnel-open-remote-port-type
May 27, 2026
Merged

fix(tunnel:open): cast remote port to int#91
pjcdawkins merged 1 commit into
mainfrom
fix/tunnel-open-remote-port-type

Conversation

@pjcdawkins
Copy link
Copy Markdown
Contributor

Summary

upsun tunnel:open crashes with a fatal TypeError before the tunnel is created:

Tunnel::__construct(): Argument #4 ($remotePort) must be of type int, string given

The port value in the relationship metadata returned by the API arrives as a string. Tunnel::__construct types $remotePort as int, so constructing the Tunnel blows up at TunnelManager.php:54.

Fix: cast $service['port'] to int at the call site. Added a regression test that reproduces the exact failure from #72 without the fix and passes with it.

Closes #72.

Note: PR #89 fixed the sibling $localPort cast for tunnel:single --port on Windows, but didn't touch the $remotePort path used by tunnel:open.

🤖 Generated with Claude Code

The relationship metadata returned by the API delivers `port` as a
string. Tunnel::__construct types $remotePort as int, so tunnel:open
crashed with a TypeError when constructing the Tunnel object.

Cast $service['port'] to int at the call site.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 26, 2026 17:15
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

This PR fixes a tunnel:open crash by ensuring relationship metadata ports are passed to Tunnel with the expected integer type.

Changes:

  • Casts the remote service port to int when creating a tunnel.
  • Adds a regression test covering string-valued relationship ports.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
legacy/src/Service/TunnelManager.php Casts the service port value before constructing Tunnel.
legacy/tests/Service/TunnelManagerTest.php Adds coverage for creating a tunnel from API-style string port metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pjcdawkins pjcdawkins merged commit 383c895 into main May 27, 2026
5 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.

Uncaught TypeError when using upsun tunnel:open

2 participants