diff --git a/apiserver/action/run.go b/apiserver/action/run.go
index <HASH>..<HASH> 100644
--- a/apiserver/action/run.go
+++ b/apiserver/action/run.go
@@ -33,6 +33,9 @@ func getAllUnitNames(st *state.State, units, services []string) (result []names.
 		}
 	}
 	for _, unitName := range unitsSet.SortedValues() {
+		if !names.IsValidUnit(unitName) {
+			return nil, errors.Errorf("invalid unit name %q", unitName)
+		}
 		result = append(result, names.NewUnitTag(unitName))
 	}
 	return result, nil
diff --git a/apiserver/action/run_test.go b/apiserver/action/run_test.go
index <HASH>..<HASH> 100644
--- a/apiserver/action/run_test.go
+++ b/apiserver/action/run_test.go
@@ -92,6 +92,14 @@ func (s *runSuite) TestGetAllUnitNames(c *gc.C) {
 	}{{
 		message: "no units, expected nil slice",
 	}, {
+		message:  "asking for an empty string service",
+		services: []string{""},
+		error:    `"" is not a valid service name`,
+	}, {
+		message: "asking for an empty string unit",
+		units:   []string{""},
+		error:   `invalid unit name ""`,
+	}, {
 		message:  "asking for a service that isn't there",
 		services: []string{"foo"},
 		error:    `service "foo" not found`,
apiserver/action: Fixed a potential panic