Skip to content

Commit 9d55e93

Browse files
committed
Fix auto-deploy not throwing proper exception
1 parent b850256 commit 9d55e93

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
2424
* File manager rename field would not disappear when pressing the escape key in chrome. [#121](https://github.com/Pterodactyl/Panel/issues/121)
2525
* Fixes bug where server image assigned was not being saved to the database.
2626
* Fixes instances where selecting auto-deploy would not hide the node selection dropdown.
27+
* Fixes bug in auto-deployment that would throw a `ModelNotFoundException` if the location passed was not valid. Not normally an issue in the panel, but caused display isses for the API.
2728

2829
## v0.5.0-pre.1 (Bodacious Boreopterus)
2930

app/Services/DeploymentService.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ public static function randomLocation()
6161
*/
6262
public static function randomNode($location, array $not = [])
6363
{
64-
$useLocation = Models\Location::findOrFail($location);
65-
$node = Models\Node::where('location', $useLocation->id)->where('public', 1)->whereNotIn('id', $not)->inRandomOrder()->first();
64+
$useLocation = Models\Location::where('id', $location)->first();
65+
if (!$useLocation) {
66+
throw new DisplayException("The location passed was not valid and could not be found.");
67+
}
6668

69+
$node = Models\Node::where('location', $useLocation->id)->where('public', 1)->whereNotIn('id', $not)->inRandomOrder()->first();
6770
if (!$node) {
6871
throw new DisplayException("Unable to find a node in location {$useLocation->short} (id: {$useLocation->id}) that is available and has space.");
6972
}

0 commit comments

Comments
 (0)