Skip to content

[master] [bug] Fix crash in ssh:configure when key generation fails#149

Open
JoshSalway wants to merge 1 commit intolaravel:masterfrom
JoshSalway:fix/ssh-key-creation-null-check
Open

[master] [bug] Fix crash in ssh:configure when key generation fails#149
JoshSalway wants to merge 1 commit intolaravel:masterfrom
JoshSalway:fix/ssh-key-creation-null-check

Conversation

@JoshSalway
Copy link
Copy Markdown

Summary

KeyRepository::create() calls keysFactory.php via exec() and json_decodes the result without checking for failure. If the subprocess fails (wrong PHP binary, missing dependencies, PHAR path issues), json_decode returns null and the subsequent array access crashes with:

Trying to access array offset on null

This adds an abort_if guard with a helpful error message pointing to the script that failed to execute.

Fixes #96

Before

$ forge ssh:configure
  An unexpected error occured.
  - Error Message: Trying to access array offset on null.

After

$ forge ssh:configure
  Failed to generate SSH key. Ensure PHP can execute /path/to/scripts/keysFactory.php

Testing

forge ssh:configure
# If key generation fails, should show a clear error message
# instead of "Trying to access array offset on null"

Note: I don't have a Laravel Forge subscription and was unable to end-to-end test. I currently use Laravel Cloud for my hosting needs instead.

KeyRepository::create() calls keysFactory.php via exec() and
json_decodes the result without checking for failure. If the
subprocess fails (wrong PHP binary, missing deps, PHAR path
issues), json_decode returns null and the subsequent array
access crashes with "Trying to access array offset on null".

This adds an abort_if guard with a helpful error message pointing
to the script that failed.

Fixes laravel#96
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

Thanks for submitting a PR!

Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

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.

forge ssh:configure

1 participant