Repository: PrefectHQ/prefect

Issue:
Prevent creating flows with schedules if the flow has required parameters
Flows with required parameters can't be scheduled (because the parameter values aren't known!). It would be nice if users were made aware of this before they submit the flow; otherwise they won't learn until they try to activate scheduling in cloud. 

Perhaps the new `Client` (in #374) could prevent submitting flows to Cloud if they:
1. Have a Schedule
2. Have `any([p.required for p in flow.parameters()])`


Discussion:
With the changes to Flow project / version attributes + the Client, we need to revisit our CLI commands for submitting / deploying flows to cloud anyway

Resolving patch:
diff --git a/src/prefect/client/client.py b/src/prefect/client/client.py
--- a/src/prefect/client/client.py
+++ b/src/prefect/client/client.py
@@ -258,6 +258,12 @@ def deploy(
         Returns:
             - GraphQLResult: information about the newly created flow (e.g., its "id")
         """
+        required_parameters = flow.parameters(only_required=True)
+        if flow.schedule is not None and required_parameters:
+            raise ValueError(
+                "Flows with required parameters can not be scheduled automatically."
+            )
+
         create_mutation = {
             "mutation($input: createFlowInput!)": {
                 "createFlow(input: $input)": {"flow": {"id"}}
diff --git a/src/prefect/client/secrets.py b/src/prefect/client/secrets.py
--- a/src/prefect/client/secrets.py
+++ b/src/prefect/client/secrets.py
@@ -40,9 +40,7 @@ def get(self) -> Optional[str]:
             return client.graphql(  # type: ignore
                 """
                 query($name: String!) {
-                    secret(name: $name) {
-                        value
-                    }
+                    secretValue(name: $name)
                 }""",
                 name=self.name,
-            ).secret.value
+            ).secretValue


Test patch:
diff --git a/tests/client/test_client.py b/tests/client/test_client.py
--- a/tests/client/test_client.py
+++ b/tests/client/test_client.py
@@ -322,6 +322,30 @@ def test_client_deploy(monkeypatch):
     assert result.id == "long-id"
 
 
+@pytest.mark.parametrize("active", [False, True])
+def test_client_deploy_rejects_setting_active_schedules_for_flows_with_req_params(
+    active, monkeypatch
+):
+    post = MagicMock()
+    monkeypatch.setattr("requests.post", post)
+    with set_temporary_config(
+        {"cloud.api": "http://my-cloud.foo", "cloud.auth_token": "secret_token"}
+    ):
+        client = Client()
+
+    flow = prefect.Flow(name="test", schedule=prefect.schedules.Schedule())
+    flow.add_task(prefect.Parameter("x", required=True))
+
+    with pytest.raises(ValueError) as exc:
+        result = client.deploy(
+            flow, project_id="my-default-0000", set_schedule_active=active
+        )
+    assert (
+        str(exc.value)
+        == "Flows with required parameters can not be scheduled automatically."
+    )
+
+
 def test_get_flow_run_info(monkeypatch):
     response = """
 {
diff --git a/tests/client/test_secrets.py b/tests/client/test_secrets.py
--- a/tests/client/test_secrets.py
+++ b/tests/client/test_secrets.py
@@ -1,3 +1,4 @@
+import json
 import pytest
 from unittest.mock import MagicMock
 
@@ -35,3 +36,27 @@ def test_secret_value_depends_on_use_local_secrets():
             with pytest.raises(ValueError) as exc:
                 secret.get()
             assert "Client.login" in str(exc.value)
+
+
+def test_secrets_use_client(monkeypatch):
+    response = """
+{
+    "secretValue": "1234"
+}
+    """
+    post = MagicMock(
+        return_value=MagicMock(
+            json=MagicMock(return_value=dict(data=json.loads(response)))
+        )
+    )
+    monkeypatch.setattr("requests.post", post)
+    with set_temporary_config(
+        {
+            "cloud.api": "http://my-cloud.foo",
+            "cloud.auth_token": "secret_token",
+            "cloud.use_local_secrets": False,
+        }
+    ):
+        my_secret = Secret(name="the-key")
+        val = my_secret.get()
+    assert val == "1234"