Repository: cleanlab/cleanlab

Issue:
Calling Datalab.get_issues() when there are no issues throws an error
When finding issues using code below (on a dataset where there are no issues), the following attempts (1,2) throw error:

```python
lab = cleanlab.Datalab(data=train[numerical], label_name="label", task="regression")
lab.find_issues(pred_probs=y_train_pred)
```
1.`label_quality_scores = lab.get_issues('label')['label_issues']`
2.`label_quality_scores = lab.get_issues('label')`

Instead should print something like "There are no isses" 


Discussion:

Resolving patch:
diff --git a/cleanlab/datalab/datalab.py b/cleanlab/datalab/datalab.py
--- a/cleanlab/datalab/datalab.py
+++ b/cleanlab/datalab/datalab.py
@@ -513,6 +513,15 @@ def get_issues(self, issue_name: Optional[str] = None) -> pd.DataFrame:
 
             Additional columns may be present in the DataFrame depending on the type of issue specified.
         """
+
+        # Validate issue_name
+        if issue_name is not None and issue_name not in self.list_possible_issue_types():
+            raise ValueError(
+                f"""Invalid issue_name: {issue_name}. Please specify a valid issue_name from the list of possible issue types.
+            Either, specify one of the following: {self.list_possible_issue_types()}
+            or set issue_name as None to get all issue types.
+            """
+            )
         return self.data_issues.get_issues(issue_name=issue_name)
 
     def get_issue_summary(self, issue_name: Optional[str] = None) -> pd.DataFrame:
diff --git a/cleanlab/datalab/internal/data_issues.py b/cleanlab/datalab/internal/data_issues.py
--- a/cleanlab/datalab/internal/data_issues.py
+++ b/cleanlab/datalab/internal/data_issues.py
@@ -242,12 +242,31 @@ def get_issues(self, issue_name: Optional[str] = None) -> pd.DataFrame:
 
             Additional columns may be present in the DataFrame depending on the type of issue specified.
         """
+        if self.issues.empty:
+            raise ValueError(
+                """No issues available for retrieval. Please check the following before using `get_issues`:
+                1. Ensure `find_issues` was executed. If not, please run it with the necessary parameters.
+                2. If `find_issues` was run but you're seeing this message,
+                    it may have encountered limitations preventing full analysis.
+                    However, partial checks can still provide valuable insights.
+            Review `find_issues` output carefully for any specific actions needed
+            to facilitate a more comprehensive analysis before calling `get_issues`.
+            """
+            )
         if issue_name is None:
             return self.issues
 
         columns = [col for col in self.issues.columns if issue_name in col]
         if not columns:
-            raise ValueError(f"No columns found for issue type '{issue_name}'.")
+            raise ValueError(
+                f"""No columns found for issue type '{issue_name}'. Ensure the following:
+                1. `find_issues` has been executed. If it hasn't, please run it.
+                2. Check `find_issues` output to verify that the issue type '{issue_name}' was included in the checks to
+                    ensure it was not excluded accidentally before the audit.
+                3. Review `find_issues` output for any errors or warnings that might indicate the check for '{issue_name}' issues failed to complete.
+                    This can provide better insights into what adjustments may be necessary.
+            """
+            )
         specific_issues = self.issues[columns]
         info = self.get_info(issue_name=issue_name)
 


Test patch:
diff --git a/tests/datalab/datalab/test_datalab.py b/tests/datalab/datalab/test_datalab.py
--- a/tests/datalab/datalab/test_datalab.py
+++ b/tests/datalab/datalab/test_datalab.py
@@ -1708,3 +1708,51 @@ def test_report_with_one_label_issue(self, data):
         assert report.startswith(
             expected_header
         ), "Report should contain a message for one issue found"
+
+
+@pytest.mark.issue986
+class TestDatalabGetIssuesMethod:
+
+    @pytest.fixture
+    def lab(self):
+        """Testing label issues in regression task."""
+        dataset = {"X": [[1, 2], [3, 4], [5, 6]], "y": [0, 0.5, 1.0]}
+        return Datalab(data=dataset, label_name="y", task="regression")
+
+    def test_get_issues_with_unsuccessful_find_issues(self, lab):
+        with patch("builtins.print") as mock_print:
+            # Running 5-fold CV on 3 samples shouldn't work for detecting label issues.
+            lab.find_issues(features=np.array(lab.data["X"]), issue_types={"label": {}})
+            mock_print.assert_any_call(
+                "Error in label: There are too few examples to conduct 5-fold cross validation. "
+                "You can either reduce cv_n_folds for cross validation, or decrease k to exclude less data."
+            )
+            mock_print.assert_any_call(
+                "Failed to check for these issue types: [RegressionLabelIssueManager]"
+            )
+
+        # The issues should be empty,
+        assert lab.issues.empty
+
+        # so the getter method should raise an error.
+        with pytest.raises(
+            ValueError, match="No issues available for retrieval. Please check the following"
+        ):
+            lab.get_issues("label")
+
+        # Run issue check that only needs features
+        lab.find_issues(features=np.array(lab.data["X"]), issue_types={"null": {}})
+
+        # The label issues we searched for should not be present
+        assert not lab.issues.empty
+        with pytest.raises(ValueError, match="No columns found for issue type 'label'."):
+            lab.get_issues("label")
+
+    def test_invalid_issue_name(self, lab):
+        lab.find_issues(features=np.array(lab.data["X"]), issue_types={"null": {}})
+
+        assert not lab.issues.empty
+
+        invalid_issue_name = "nul"
+        with pytest.raises(ValueError, match=f"Invalid issue_name: {invalid_issue_name}."):
+            lab.get_issues(issue_name=invalid_issue_name)