From 2d5d7e8e9888a210dc9a4f7952bb1c709fd790c4 Mon Sep 17 00:00:00 2001 From: Madison Swain-Bowden Date: Tue, 27 Jul 2021 14:52:55 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20Allow=20non-default=20source=20S?= =?UTF-8?q?FTP=20port=20(#4953)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Allow SFTP to define port * Define port as a string * Provide a clearer error if port parsing fails --- .../connectors/source-file/source_file/client.py | 8 +++++++- .../connectors/source-file/source_file/spec.json | 12 ++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/airbyte-integrations/connectors/source-file/source_file/client.py b/airbyte-integrations/connectors/source-file/source_file/client.py index 08b7f3ff6bc25..221d4b372a1dc 100644 --- a/airbyte-integrations/connectors/source-file/source_file/client.py +++ b/airbyte-integrations/connectors/source-file/source_file/client.py @@ -119,7 +119,13 @@ def _open(self, binary): elif storage in ("ssh://", "scp://", "sftp://"): user = self._provider["user"] host = self._provider["host"] - port = self._provider.get("port", 22) + # TODO: Remove int casting when https://github.com/airbytehq/airbyte/issues/4952 is addressed + # TODO: The "port" field in spec.json must also be changed + _port_value = self._provider.get("port", 22) + try: + port = int(_port_value) + except ValueError as err: + raise ValueError(f"{_port_value} is not a valid integer for the port") from err # Explicitly turn off ssh keys stored in ~/.ssh transport_params = {"connect_kwargs": {"look_for_keys": False}} if "password" in self._provider: diff --git a/airbyte-integrations/connectors/source-file/source_file/spec.json b/airbyte-integrations/connectors/source-file/source_file/spec.json index 054f776f783e2..1ebc2d9159528 100644 --- a/airbyte-integrations/connectors/source-file/source_file/spec.json +++ b/airbyte-integrations/connectors/source-file/source_file/spec.json @@ -123,8 +123,8 @@ "type": "string" }, "port": { - "type": "number", - "default": 22 + "type": "string", + "default": "22" } } }, @@ -148,8 +148,8 @@ "type": "string" }, "port": { - "type": "number", - "default": 22 + "type": "string", + "default": "22" } } }, @@ -171,6 +171,10 @@ }, "host": { "type": "string" + }, + "port": { + "type": "string", + "default": "22" } } },