-
Notifications
You must be signed in to change notification settings - Fork 235
fix: ensure IP restriction error handling for run:inside and logs commands #3389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
michaelmalave
merged 16 commits into
main
from
mm/chore/uniform-errors-outside-trusted-ips
Nov 21, 2025
Merged
fix: ensure IP restriction error handling for run:inside and logs commands #3389
michaelmalave
merged 16 commits into
main
from
mm/chore/uniform-errors-outside-trusted-ips
Nov 21, 2025
+257
−235
Conversation
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
…ands. Prevents silent failures when commands are executed outside trusted IP ranges
…tside-trusted-ips
SandyPantsLai
approved these changes
Nov 5, 2025
…inguish between 403 error types
SandyPantsLai
approved these changes
Nov 17, 2025
…com:heroku/cli into mm/chore/uniform-errors-outside-trusted-ips
…tside-trusted-ips
tlowrimore-heroku
approved these changes
Nov 21, 2025
Contributor
tlowrimore-heroku
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This looks great! I really like the AbortController-based clean-up logic.
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
Fixed silent failure issue in
heroku run:insideand improved error messages inheroku logswhen executed outside trusted IP ranges. Added uniform error handling for 403 HTTP responses to provide clear error messages instead of silent failures or generic errors.Type of Change
Note: Add a
!after your change type to denote a breaking change.Testing
Follow guide for staging heroku environment here: staging setup.
get current webserver
Confirm ip restrictions (should be empty). Use the remove command if needed:
Run commands against test space + app with IP restrictions enabled:
Both should return the same error:
Error: You can't access this space from your IP address. Contact your team admin.Additional Context
Root Cause:
run:insidecommand failed silently when IP restrictions were active because the HTTPS request in the SSH connection path received a 403 response but had no handler for it, causing the Promise to hang indefinitely waiting for anupgradeevent that never came.logscommand displayed generic error messages for 403 responses because EventSource doesn't expose HTTP response bodies, making it impossible to distinguish between IP restrictions (immediate 403) and stream expiration errors (delayed 403 after messages were received).Fix Applied:
dyno.ts: Added HTTP response handler in_connect()method to check for 403 status codes before the upgrade event and reject the Promise with a user-friendly error message: "You can't access this space from your IP address. Contact your team admin."log-displayer.ts: Implemented connection state tracking using ahasReceivedMessagesflag to distinguish between immediate 403 errors (IP restrictions) and delayed 403 errors (stream expiration). The error handler now:hasReceivedMessagesflagImplementation Details:
hasReceivedMessagesboolean flag that is set totruewhen the first message event is receivedResolved usage:

Related Issue
Closes @W-20247783@