Skip to content

Commit 10d7bea

Browse files
authored
Source File: Fix special characters bug (#21012)
* Source File: Fix special characters bug * Source File: bump version; update docs * Source File: update SSH credentials in unit tests * Source File: bump version (secure) * Source File: update resources manually
1 parent 4251dfe commit 10d7bea

File tree

8 files changed

+18
-13
lines changed

8 files changed

+18
-13
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@
489489
- name: File
490490
sourceDefinitionId: 778daa7c-feaf-4db6-96f3-70fd645acc77
491491
dockerRepository: airbyte/source-file
492-
dockerImageTag: 0.2.32
492+
dockerImageTag: 0.2.33
493493
documentationUrl: https://docs.airbyte.com/integrations/sources/file
494494
icon: file.svg
495495
sourceType: file

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4041,7 +4041,7 @@
40414041
supportsNormalization: false
40424042
supportsDBT: false
40434043
supported_destination_sync_modes: []
4044-
- dockerImage: "airbyte/source-file:0.2.32"
4044+
- dockerImage: "airbyte/source-file:0.2.33"
40454045
spec:
40464046
documentationUrl: "https://docs.airbyte.com/integrations/sources/file"
40474047
connectionSpecification:

airbyte-integrations/connectors/source-file-secure/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ RUN pip install .
99
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1010
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1111

12-
LABEL io.airbyte.version=0.2.32
12+
LABEL io.airbyte.version=0.2.33
1313
LABEL io.airbyte.name=airbyte/source-file-secure

airbyte-integrations/connectors/source-file/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ COPY source_file ./source_file
1717
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1818
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1919

20-
LABEL io.airbyte.version=0.2.32
20+
LABEL io.airbyte.version=0.2.33
2121
LABEL io.airbyte.name=airbyte/source-file

airbyte-integrations/connectors/source-file/integration_tests/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def is_ssh_ready(ip, port):
7373
ip,
7474
port=port,
7575
username="user1",
76-
password="pass1",
76+
password="abc123@456#",
7777
)
7878
return True
7979
except (SSHException, socket.error):
@@ -93,9 +93,9 @@ def ssh_service(docker_ip, docker_services):
9393
def provider_config(ssh_service):
9494
def lookup(name):
9595
providers = {
96-
"ssh": dict(storage="SSH", host=ssh_service, user="user1", password="pass1", port=2222),
97-
"scp": dict(storage="SCP", host=ssh_service, user="user1", password="pass1", port=2222),
98-
"sftp": dict(storage="SFTP", host=ssh_service, user="user1", password="pass1", port=100),
96+
"ssh": dict(storage="SSH", host=ssh_service, user="user1", password="abc123@456#", port=2222),
97+
"scp": dict(storage="SCP", host=ssh_service, user="user1", password="abc123@456#", port=2222),
98+
"sftp": dict(storage="SFTP", host=ssh_service, user="user1", password="abc123@456#", port=100),
9999
"gcs": dict(storage="GCS"),
100100
"s3": dict(storage="S3"),
101101
"azure": dict(storage="AzBlob"),

airbyte-integrations/connectors/source-file/integration_tests/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ services:
66
- "2222:22"
77
volumes:
88
- ./sample_files:/home/user1/files
9-
command: user1:pass1:1001
9+
command: user1:abc123@456#:1001

airbyte-integrations/connectors/source-file/source_file/client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import json
77
import tempfile
88
import traceback
9+
import urllib
910
from os import environ
1011
from typing import Iterable
1112
from urllib.parse import urlparse
@@ -108,8 +109,11 @@ def _open(self):
108109
port = self._provider["port"]
109110
return smart_open.open(f"webhdfs://{host}:{port}/{url}", **self.args)
110111
elif storage in ("ssh://", "scp://", "sftp://"):
111-
user = self._provider["user"]
112-
host = self._provider["host"]
112+
# We need to quote parameters to deal with special characters
113+
# https://bugs.python.org/issue18140
114+
user = urllib.parse.quote(self._provider["user"])
115+
host = urllib.parse.quote(self._provider["host"])
116+
url = urllib.parse.quote(url)
113117
# TODO: Remove int casting when https://github.com/airbytehq/airbyte/issues/4952 is addressed
114118
# TODO: The "port" field in spec.json must also be changed
115119
_port_value = self._provider.get("port", 22)
@@ -120,7 +124,7 @@ def _open(self):
120124
# Explicitly turn off ssh keys stored in ~/.ssh
121125
transport_params = {"connect_kwargs": {"look_for_keys": False}, "timeout": SSH_TIMEOUT}
122126
if "password" in self._provider:
123-
password = self._provider["password"]
127+
password = urllib.parse.quote(self._provider["password"])
124128
uri = f"{storage}{user}:{password}@{host}:{port}/{url}"
125129
else:
126130
uri = f"{storage}{user}@{host}:{port}/{url}"

docs/integrations/sources/file.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ In order to read large files from a remote location, this connector uses the [sm
138138
## Changelog
139139

140140
| Version | Date | Pull Request | Subject |
141-
|:--------|:-----------| :------------------------------------------------------- |:---------------------------------------------------------|
141+
|:--------|:-----------|:---------------------------------------------------------|:---------------------------------------------------------|
142+
| 0.2.33 | 2023-01-04 | [21012](https://github.com/airbytehq/airbyte/pull/21012) | Fix special characters bug |
142143
| 0.2.32 | 2022-12-21 | [20740](https://github.com/airbytehq/airbyte/pull/20740) | Source File: increase SSH timeout to 60s |
143144
| 0.2.31 | 2022-11-17 | [19567](https://github.com/airbytehq/airbyte/pull/19567) | Source File: bump 0.2.31 |
144145
| 0.2.30 | 2022-11-10 | [19222](https://github.com/airbytehq/airbyte/pull/19222) | Use AirbyteConnectionStatus for "check" command |

0 commit comments

Comments
 (0)