Repository: skypilot-org/skypilot
Pull request #2756 (2023-11-05 05:45:33)

[Config] Fix ssh proxy command to be null
<!-- Describe the changes in this PR -->

A user reported that the `sky launch` fails when the following `config.yaml` is provided:
```
aws:
      instance_tags:
          mytag: myvalue
      ssh_proxy_command:
          eu-west-1: null
          us-east-1: null
      use_internal_ips: true
      vpc_name: abc
```

This is due to our recent schema check for `config.yaml` in #2645


<!-- Describe the tests ran -->
<!-- Unit tests (tests/test_*.py) are part of GitHub CI; below are tests that launch on the cloud. -->

Tested (run the relevant ones):

- [ ] Code formatting: `bash format.sh`
- [x] Any manual or new tests for this PR (please specify below)
  - [x] `sky launch -c test --cloud aws`
- [ ] All smoke tests: `pytest tests/test_smoke.py` 
- [ ] Relevant individual smoke tests: `pytest tests/test_smoke.py::test_fill_in_the_name` 
- [ ] Backward compatibility tests: `bash tests/backward_comaptibility_tests.sh`



Patch:
diff --git a/sky/utils/schemas.py b/sky/utils/schemas.py
index 0267b7a26..20453c49e 100644
--- a/sky/utils/schemas.py
+++ b/sky/utils/schemas.py
@@ -323,7 +323,14 @@ def get_config_schema():
                             'type': 'object',
                             'required': [],
                             'additionalProperties': {
-                                'type': 'string',
+                                'anyOf': [
+                                    {
+                                        'type': 'string'
+                                    },
+                                    {
+                                        'type': 'null'
+                                    },
+                                ]
                             }
                         }]
                     },


Test patch:
diff --git a/tests/test_config.py b/tests/test_config.py
index b4053523d..52ff17676 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -58,6 +58,31 @@ def test_empty_config(monkeypatch, tmp_path) -> None:
     _check_empty_config()
 
 
+def test_valid_null_proxy_config(monkeypatch, tmp_path) -> None:
+    """Test that the config is not loaded if the config file is empty."""
+    with open(tmp_path / 'valid.yaml', 'w') as f:
+        f.write(f"""\
+        aws:
+            instance_tags:
+                mytag: myvalue
+            ssh_proxy_command:
+                eu-west-1: null
+                us-east-1: null
+            use_internal_ips: true
+            vpc_name: abc
+
+        spot:
+            controller:
+                resources:
+                    disk_size: 256
+        """)
+    monkeypatch.setattr(skypilot_config, 'CONFIG_PATH', tmp_path / 'valid.yaml')
+    _reload_config()
+    proxy_config = skypilot_config.get_nested(
+        ('aws', 'ssh_proxy_command', 'eu-west-1'), 'default')
+    assert proxy_config is None, proxy_config
+
+
 def test_invalid_field_config(monkeypatch, tmp_path) -> None:
     """Test that the config is not loaded if the config file contains unknown field."""
     config_path = tmp_path / 'invalid.yaml'