dq-export-connector 0.1.0.dev9__tar.gz → 0.1.0.dev10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/PKG-INFO +1 -1
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/_models/bucket_validation_result.py +1 -2
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/_models/export_report.py +1 -2
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/bucket/datasets.py +11 -1
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/bucket/export.py +2 -2
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/bucket/store.py +41 -5
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/pyproject.toml +1 -1
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/tests/test_runner.py +31 -5
- dq_export_connector-0.1.0.dev10/tests/test_store.py +110 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/uv.lock +1 -1
- dq_export_connector-0.1.0.dev9/tests/test_store.py +0 -46
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/.gitignore +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/.python-version +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/README.md +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/__init__.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/_models/__init__.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/_models/export_connector_credentials.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/_models/export_worker_config.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/bucket/__init__.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/bucket/paths.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/bucket/upload.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/bucket/validate.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/errors.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/log.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/redact.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/report.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/runner.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/scripts/codegen-models.sh +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/tests/test_live_buckets.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/tests/test_models_are_current.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/tests/test_paths.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/tests/test_redact.py +0 -0
- {dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/tests/test_upload.py +0 -0
|
@@ -21,8 +21,7 @@ class ExportMessage(BaseModel):
|
|
|
21
21
|
message: Annotated[
|
|
22
22
|
str,
|
|
23
23
|
Field(
|
|
24
|
-
description='Safe to show to the user: no credentials and no dataset values.
|
|
25
|
-
max_length=1000,
|
|
24
|
+
description='Safe to show to the user: no credentials and no dataset values. Writers\ncut it to 1,000 characters, marking the cut with `…`.'
|
|
26
25
|
),
|
|
27
26
|
]
|
|
28
27
|
|
|
@@ -61,8 +61,7 @@ class ExportMessage(BaseModel):
|
|
|
61
61
|
message: Annotated[
|
|
62
62
|
str,
|
|
63
63
|
Field(
|
|
64
|
-
description='Safe to show to the user: no credentials and no dataset values.
|
|
65
|
-
max_length=1000,
|
|
64
|
+
description='Safe to show to the user: no credentials and no dataset values. Writers\ncut it to 1,000 characters, marking the cut with `…`.'
|
|
66
65
|
),
|
|
67
66
|
]
|
|
68
67
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""How an Input's dataset maps to files. A ZIP whose entries are all stored
|
|
2
2
|
without compression is unpacked, each entry keeping its path. Anything else,
|
|
3
|
-
including a ZIP with a compressed entry, is one raw file named `data`.
|
|
3
|
+
including a ZIP with a compressed entry, is one raw file named `data`. A
|
|
4
|
+
stored ZIP with an encrypted entry can't be read."""
|
|
4
5
|
|
|
5
6
|
from __future__ import annotations
|
|
6
7
|
|
|
@@ -12,6 +13,12 @@ from pathlib import Path
|
|
|
12
13
|
from typing import BinaryIO
|
|
13
14
|
|
|
14
15
|
RAW_FILE_NAME = "data"
|
|
16
|
+
# The ZIP general purpose flag of an encrypted entry.
|
|
17
|
+
_ENCRYPTED = 0x1
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class UnreadableDatasetError(Exception):
|
|
21
|
+
pass
|
|
15
22
|
|
|
16
23
|
|
|
17
24
|
@dataclass(frozen=True)
|
|
@@ -46,6 +53,9 @@ def open_dataset(dataset_path: Path) -> Iterator[tuple[Layout, _Reader]]:
|
|
|
46
53
|
size = dataset_path.stat().st_size
|
|
47
54
|
yield Layout([DatasetFile(RAW_FILE_NAME, size)], "a ZIP with compressed entries"), _RawReader(dataset_path)
|
|
48
55
|
return
|
|
56
|
+
encrypted = [entry.filename for entry in entries if entry.flag_bits & _ENCRYPTED]
|
|
57
|
+
if encrypted:
|
|
58
|
+
raise UnreadableDatasetError(f"its ZIP entry '{encrypted[0]}' is encrypted")
|
|
49
59
|
files = [DatasetFile(entry.filename, entry.file_size) for entry in entries if not entry.is_dir()]
|
|
50
60
|
yield Layout(files, None), _ZipReader(archive)
|
|
51
61
|
|
|
@@ -21,7 +21,7 @@ from dq_export_connector._models.export_report import (
|
|
|
21
21
|
ExportTotals,
|
|
22
22
|
)
|
|
23
23
|
from dq_export_connector._models.export_worker_config import BucketInput, ExportConnectorKind1, ProvisionedPolicy
|
|
24
|
-
from dq_export_connector.bucket.datasets import DatasetFile, open_dataset
|
|
24
|
+
from dq_export_connector.bucket.datasets import DatasetFile, UnreadableDatasetError, open_dataset
|
|
25
25
|
from dq_export_connector.bucket.paths import InvalidPathError, check_dataset_path, check_key, fill_date_tokens, join_key
|
|
26
26
|
from dq_export_connector.bucket.store import StorageError, classify_error, failure_sentence, location
|
|
27
27
|
from dq_export_connector.bucket.upload import plan_upload, upload
|
|
@@ -152,7 +152,7 @@ def _reading(destination: str) -> Iterator[None]:
|
|
|
152
152
|
entry cut short, when its entry is read."""
|
|
153
153
|
try:
|
|
154
154
|
yield
|
|
155
|
-
except (OSError, EOFError, zipfile.BadZipFile) as error:
|
|
155
|
+
except (OSError, EOFError, zipfile.BadZipFile, UnreadableDatasetError) as error:
|
|
156
156
|
raise ExportConnectorError(
|
|
157
157
|
ErrorCode.READ_FAILED,
|
|
158
158
|
f"The dataset for '{destination}/' couldn't be read: {str(error) or type(error).__name__}",
|
|
@@ -3,6 +3,7 @@ failures map to."""
|
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
6
|
+
import re
|
|
6
7
|
from collections.abc import Callable
|
|
7
8
|
from datetime import timedelta
|
|
8
9
|
from typing import TYPE_CHECKING, Any, TypeVar
|
|
@@ -24,6 +25,7 @@ from dq_export_connector._models.export_worker_config import (
|
|
|
24
25
|
)
|
|
25
26
|
|
|
26
27
|
from dq_export_connector.errors import ErrorCode, ExportConnectorError
|
|
28
|
+
from dq_export_connector.redact import MASK
|
|
27
29
|
|
|
28
30
|
if TYPE_CHECKING:
|
|
29
31
|
from obstore.store import ClientConfig, RetryConfig
|
|
@@ -57,10 +59,23 @@ CLIENT_CONFIG: ClientConfig = {
|
|
|
57
59
|
T = TypeVar("T")
|
|
58
60
|
|
|
59
61
|
|
|
62
|
+
_HTTP_ERROR = re.compile(r"HttpError \{\s*kind: (?P<kind>\w+),\s*source: reqwest::Error \{(?P<source>.*)", re.DOTALL)
|
|
63
|
+
_STRING_LITERAL = re.compile(r'"((?:[^"\\]|\\.)*)"')
|
|
64
|
+
|
|
65
|
+
|
|
60
66
|
def describe(error: Exception) -> str:
|
|
61
|
-
"""obstore's message without the `Debug source:` dump it appends
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
"""obstore's message without the `Debug source:` dump it appends. For a
|
|
68
|
+
request that couldn't be sent, the message stops at "error sending
|
|
69
|
+
request", so the causes the dump holds, such as a DNS failure or a refused
|
|
70
|
+
connection, are appended."""
|
|
71
|
+
message, _, dump = str(error).partition("\n\nDebug source:")
|
|
72
|
+
http_error = _HTTP_ERROR.search(dump)
|
|
73
|
+
if http_error is None:
|
|
74
|
+
return message
|
|
75
|
+
causes = _STRING_LITERAL.findall(http_error["source"])
|
|
76
|
+
if http_error["kind"] == "Timeout":
|
|
77
|
+
causes.append("timed out")
|
|
78
|
+
return ": ".join([message, *causes])
|
|
64
79
|
|
|
65
80
|
|
|
66
81
|
class StorageError(Exception):
|
|
@@ -199,14 +214,35 @@ def failure_sentence(code: ErrorCode, where: str) -> str:
|
|
|
199
214
|
return f"The {where} returned an error"
|
|
200
215
|
|
|
201
216
|
|
|
217
|
+
# How obstore's errors for credentials it can't parse begin. S3's keys are only
|
|
218
|
+
# checked by a request.
|
|
219
|
+
_CREDENTIAL_PARSE_ERRORS = (
|
|
220
|
+
"Generic MicrosoftAzure error: Missing component in SAS query pair",
|
|
221
|
+
"Generic MicrosoftAzure error: Failed parsing an SAS key",
|
|
222
|
+
"Generic GCS error: GCP credential error:",
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
# A value serde rejects, echoed in quotes or backticks with Rust's escaping,
|
|
226
|
+
# which the redactor's variants don't always match. Backticked identifiers are
|
|
227
|
+
# field names and stay.
|
|
228
|
+
_ECHOED_VALUE = re.compile(r'"(?:[^"\\]|\\.)*"|`(?![A-Za-z_][A-Za-z0-9_]*`)[^`]*`')
|
|
229
|
+
|
|
230
|
+
|
|
202
231
|
def build_store(connection: BucketConnection, credentials: BucketCredentials) -> Any:
|
|
203
232
|
"""obstore parses the credentials here, so a malformed GCS key or Azure SAS
|
|
204
|
-
token fails before any request
|
|
233
|
+
token fails before any request, as does an address no URL can hold, such as
|
|
234
|
+
an Azure account name with a space."""
|
|
205
235
|
try:
|
|
206
236
|
return _store(connection, credentials)
|
|
207
237
|
except obstore.exceptions.BaseError as error:
|
|
238
|
+
message = describe(error)
|
|
239
|
+
if message.startswith(_CREDENTIAL_PARSE_ERRORS):
|
|
240
|
+
without_values = _ECHOED_VALUE.sub(lambda value: f"{value[0][0]}{MASK}{value[0][-1]}", message)
|
|
241
|
+
raise ExportConnectorError(
|
|
242
|
+
ErrorCode.INVALID_CREDENTIALS, f"The credentials couldn't be read: {without_values}"
|
|
243
|
+
) from error
|
|
208
244
|
raise ExportConnectorError(
|
|
209
|
-
ErrorCode.
|
|
245
|
+
ErrorCode.UNREACHABLE, f"{failure_sentence(ErrorCode.UNREACHABLE, location(connection.root))}: {message}"
|
|
210
246
|
) from error
|
|
211
247
|
|
|
212
248
|
|
|
@@ -172,17 +172,28 @@ def test_a_failed_input_stops_the_run_and_keeps_what_was_written(tmp_path, monke
|
|
|
172
172
|
)
|
|
173
173
|
|
|
174
174
|
|
|
175
|
+
def _encrypted(data):
|
|
176
|
+
"""Sets the encryption flag in the local and the central header."""
|
|
177
|
+
data = bytearray(data)
|
|
178
|
+
for signature, flags_offset in ((b"PK\x03\x04", 6), (b"PK\x01\x02", 8)):
|
|
179
|
+
data[data.index(signature) + flags_offset] |= 0x1
|
|
180
|
+
return bytes(data)
|
|
181
|
+
|
|
182
|
+
|
|
175
183
|
@pytest.mark.parametrize(
|
|
176
|
-
("corrupt", "reason"),
|
|
184
|
+
("entries", "corrupt", "reason"),
|
|
177
185
|
[
|
|
178
|
-
(lambda data: data.replace(b"hello world", b"hellO world"), "Bad CRC-32 for file 'a.csv'"),
|
|
179
|
-
(lambda data: data.replace(b"PK\x03\x04", b"PK\x00\x00", 1), "Bad magic number for file header"),
|
|
186
|
+
({"a.csv": b"hello world"}, lambda data: data.replace(b"hello world", b"hellO world"), "Bad CRC-32 for file 'a.csv'"),
|
|
187
|
+
({"a.csv": b"hello world"}, lambda data: data.replace(b"PK\x03\x04", b"PK\x00\x00", 1), "Bad magic number for file header"),
|
|
188
|
+
({"a.csv": b"hello world"}, _encrypted, "its ZIP entry 'a.csv' is encrypted"),
|
|
189
|
+
# Over 8 MiB, so the entry is read inside obstore's multipart upload.
|
|
190
|
+
({"big.csv": b"x" * 8 * 1024 * 1024 + b"y"}, lambda data: data.replace(b"xy", b"xz"), "Bad CRC-32 for file 'big.csv'"),
|
|
180
191
|
],
|
|
181
192
|
)
|
|
182
|
-
def test_a_corrupt_stored_zip_is_unreadable(tmp_path, monkeypatch, corrupt, reason):
|
|
193
|
+
def test_a_corrupt_stored_zip_is_unreadable(tmp_path, monkeypatch, entries, corrupt, reason):
|
|
183
194
|
store = MemoryStore()
|
|
184
195
|
config = _config(EXPORT, [("segA", "seg_a")])
|
|
185
|
-
_run(tmp_path, config, {"segA": corrupt(_zip(
|
|
196
|
+
_run(tmp_path, config, {"segA": corrupt(_zip(entries))}, store, monkeypatch)
|
|
186
197
|
assert (_objects(store), _report(tmp_path)) == (
|
|
187
198
|
{},
|
|
188
199
|
{
|
|
@@ -194,6 +205,21 @@ def test_a_corrupt_stored_zip_is_unreadable(tmp_path, monkeypatch, corrupt, reas
|
|
|
194
205
|
)
|
|
195
206
|
|
|
196
207
|
|
|
208
|
+
def test_an_entry_cut_short_is_unreadable(tmp_path, monkeypatch):
|
|
209
|
+
# zipfile raises a bare EOFError for an entry that ends before its size.
|
|
210
|
+
# The tests' Python checks for overlapped entries and raises BadZipFile
|
|
211
|
+
# first, so the read is replaced.
|
|
212
|
+
def cut_short(*_):
|
|
213
|
+
raise EOFError
|
|
214
|
+
|
|
215
|
+
monkeypatch.setattr(export, "upload", cut_short)
|
|
216
|
+
_run(tmp_path, _config(EXPORT, [("segA", "seg_a")]), {"segA": _zip({"a.csv": b"x"})}, MemoryStore(), monkeypatch)
|
|
217
|
+
assert _report(tmp_path)["error"] == {
|
|
218
|
+
"code": "READ_FAILED",
|
|
219
|
+
"message": "The dataset for 'seg_a/' couldn't be read: EOFError",
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
197
223
|
def test_a_long_message_is_cut_after_its_credentials_are_masked(tmp_path, monkeypatch):
|
|
198
224
|
prefix = (
|
|
199
225
|
"The bucket 'acme' in eu-central-1 returned an error, so writing 'decentriq/seg_a/data' failed after 0 of 1"
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import socket
|
|
3
|
+
from datetime import timedelta
|
|
4
|
+
|
|
5
|
+
import obstore
|
|
6
|
+
import obstore.exceptions
|
|
7
|
+
from obstore.store import S3Store
|
|
8
|
+
|
|
9
|
+
from dq_export_connector._models.export_connector_credentials import BucketCredentials
|
|
10
|
+
from dq_export_connector._models.export_worker_config import BucketConnection
|
|
11
|
+
from dq_export_connector.bucket.store import build_store, classify_error, describe
|
|
12
|
+
from dq_export_connector.errors import ErrorCode, ExportConnectorError
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _build_error(connection, credentials):
|
|
16
|
+
try:
|
|
17
|
+
build_store(BucketConnection.model_validate(connection), BucketCredentials.model_validate(credentials))
|
|
18
|
+
except ExportConnectorError as error:
|
|
19
|
+
return error.code, error.message
|
|
20
|
+
return None
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_malformed_credentials_are_invalid_before_any_request():
|
|
24
|
+
gcs = {"type": "gcs", "bucket": "b", "pathPrefix": None}
|
|
25
|
+
azure = {"type": "azureBlob", "accountName": "a", "container": "c", "pathPrefix": None}
|
|
26
|
+
decode_error = (
|
|
27
|
+
"The credentials couldn't be read: Generic GCS error: GCP credential error: Unable to decode service account"
|
|
28
|
+
" file: "
|
|
29
|
+
)
|
|
30
|
+
assert [
|
|
31
|
+
_build_error(gcs, {"gcs": {"serviceAccountJson": "not json"}}),
|
|
32
|
+
_build_error(gcs, {"gcs": {"serviceAccountJson": json.dumps({"private_key": 5})}}),
|
|
33
|
+
_build_error(gcs, {"gcs": {"serviceAccountJson": json.dumps({"client_email": "a@b"})}}),
|
|
34
|
+
_build_error(azure, {"azureBlob": {"sasToken": "garbage"}}),
|
|
35
|
+
] == [
|
|
36
|
+
(ErrorCode.INVALID_CREDENTIALS, decode_error + "expected ident at line 1 column 2"),
|
|
37
|
+
(ErrorCode.INVALID_CREDENTIALS, decode_error + "invalid type: integer `***`, expected a string at line 1 column 17"),
|
|
38
|
+
(ErrorCode.INVALID_CREDENTIALS, decode_error + "missing field `private_key` at line 1 column 23"),
|
|
39
|
+
(
|
|
40
|
+
ErrorCode.INVALID_CREDENTIALS,
|
|
41
|
+
"The credentials couldn't be read: Generic MicrosoftAzure error: Missing component in SAS query pair",
|
|
42
|
+
),
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_a_rejected_credential_is_masked_however_rust_escapes_it():
|
|
47
|
+
gcs = {"type": "gcs", "bucket": "b", "pathPrefix": None}
|
|
48
|
+
# serde quotes a rejected string as Rust's Debug does, with \u{1} for the
|
|
49
|
+
# control character, which neither of the redactor's variants matches.
|
|
50
|
+
assert _build_error(gcs, {"gcs": {"serviceAccountJson": json.dumps("SECRET\u0001KEY")}}) == (
|
|
51
|
+
ErrorCode.INVALID_CREDENTIALS,
|
|
52
|
+
"The credentials couldn't be read: Generic GCS error: GCP credential error: Unable to decode service account"
|
|
53
|
+
' file: invalid type: string "***", expected struct ServiceAccountCredentials at line 1 column 17',
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def test_an_address_no_url_can_hold_is_unreachable():
|
|
58
|
+
azure = {"type": "azureBlob", "accountName": "my account", "container": "c", "pathPrefix": None}
|
|
59
|
+
assert _build_error(azure, {"azureBlob": {"sasToken": "sv=1&sig=2"}}) == (
|
|
60
|
+
ErrorCode.UNREACHABLE,
|
|
61
|
+
"The container 'c' of account 'my account' couldn't be reached: Generic MicrosoftAzure error: Unable parse"
|
|
62
|
+
" source url. Url: https://my account.blob.core.windows.net, Error: invalid international domain name",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _put_error(port, **client_options):
|
|
67
|
+
store = S3Store(
|
|
68
|
+
bucket="b",
|
|
69
|
+
region="eu-west-1",
|
|
70
|
+
access_key_id="a",
|
|
71
|
+
secret_access_key="s",
|
|
72
|
+
endpoint=f"http://127.0.0.1:{port}",
|
|
73
|
+
retry_config={"max_retries": 0},
|
|
74
|
+
client_options={"allow_http": True, **client_options},
|
|
75
|
+
)
|
|
76
|
+
try:
|
|
77
|
+
obstore.put(store, "k", b"x")
|
|
78
|
+
except obstore.exceptions.BaseError as error:
|
|
79
|
+
# Leaves out the request's URL and duration.
|
|
80
|
+
return describe(error).split(" - ", 1)[1]
|
|
81
|
+
return None
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_a_request_that_couldnt_be_sent_keeps_its_cause():
|
|
85
|
+
with socket.socket() as closed:
|
|
86
|
+
closed.bind(("127.0.0.1", 0))
|
|
87
|
+
closed_port = closed.getsockname()[1]
|
|
88
|
+
# The kernel completes connections to a listening socket that never
|
|
89
|
+
# accepts them, so the request gets no response.
|
|
90
|
+
with socket.socket() as silent:
|
|
91
|
+
silent.bind(("127.0.0.1", 0))
|
|
92
|
+
silent.listen()
|
|
93
|
+
errors = [_put_error(closed_port), _put_error(silent.getsockname()[1], read_timeout=timedelta(milliseconds=200))]
|
|
94
|
+
assert errors == [
|
|
95
|
+
"HTTP error: error sending request: tcp connect error: Connection refused",
|
|
96
|
+
"HTTP error: error sending request: timed out",
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def test_obstores_debug_dump_is_left_out():
|
|
101
|
+
error = obstore.exceptions.GenericError("Generic S3 error: failed\n\nDebug source:\nGeneric {\n store: \"S3\",\n}")
|
|
102
|
+
assert describe(error) == "Generic S3 error: failed"
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def test_a_bucket_in_another_region_is_not_found_there():
|
|
106
|
+
error = obstore.exceptions.GenericError(
|
|
107
|
+
"Generic S3 error: Error performing PUT https://s3.us-east-1.amazonaws.com/b/k in 482ms - Received redirect"
|
|
108
|
+
" without LOCATION, this normally indicates an incorrectly configured region"
|
|
109
|
+
)
|
|
110
|
+
assert classify_error(error) == ErrorCode.DESTINATION_NOT_FOUND
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import obstore.exceptions
|
|
2
|
-
|
|
3
|
-
from dq_export_connector._models.export_connector_credentials import BucketCredentials
|
|
4
|
-
from dq_export_connector._models.export_worker_config import BucketConnection
|
|
5
|
-
from dq_export_connector.bucket.store import build_store, classify_error, describe
|
|
6
|
-
from dq_export_connector.errors import ErrorCode, ExportConnectorError
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def _build_error(connection, credentials):
|
|
10
|
-
try:
|
|
11
|
-
build_store(BucketConnection.model_validate(connection), BucketCredentials.model_validate(credentials))
|
|
12
|
-
except ExportConnectorError as error:
|
|
13
|
-
return error.code, error.message
|
|
14
|
-
return None
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def test_malformed_credentials_are_invalid_before_any_request():
|
|
18
|
-
gcs = {"type": "gcs", "bucket": "b", "pathPrefix": None}
|
|
19
|
-
azure = {"type": "azureBlob", "accountName": "a", "container": "c", "pathPrefix": None}
|
|
20
|
-
assert [
|
|
21
|
-
_build_error(gcs, {"gcs": {"serviceAccountJson": "not json"}}),
|
|
22
|
-
_build_error(azure, {"azureBlob": {"sasToken": "garbage"}}),
|
|
23
|
-
] == [
|
|
24
|
-
(
|
|
25
|
-
ErrorCode.INVALID_CREDENTIALS,
|
|
26
|
-
"The credentials couldn't be read: Generic GCS error: GCP credential error: Unable to decode service"
|
|
27
|
-
" account file: expected ident at line 1 column 2",
|
|
28
|
-
),
|
|
29
|
-
(
|
|
30
|
-
ErrorCode.INVALID_CREDENTIALS,
|
|
31
|
-
"The credentials couldn't be read: Generic MicrosoftAzure error: Missing component in SAS query pair",
|
|
32
|
-
),
|
|
33
|
-
]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def test_obstores_debug_dump_is_left_out():
|
|
37
|
-
error = obstore.exceptions.GenericError("Generic S3 error: failed\n\nDebug source:\nGeneric {\n store: \"S3\",\n}")
|
|
38
|
-
assert describe(error) == "Generic S3 error: failed"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def test_a_bucket_in_another_region_is_not_found_there():
|
|
42
|
-
error = obstore.exceptions.GenericError(
|
|
43
|
-
"Generic S3 error: Error performing PUT https://s3.us-east-1.amazonaws.com/b/k in 482ms - Received redirect"
|
|
44
|
-
" without LOCATION, this normally indicates an incorrectly configured region"
|
|
45
|
-
)
|
|
46
|
-
assert classify_error(error) == ErrorCode.DESTINATION_NOT_FOUND
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/errors.py
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/log.py
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/redact.py
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/report.py
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/dq_export_connector/runner.py
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/scripts/codegen-models.sh
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/tests/test_live_buckets.py
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev9 → dq_export_connector-0.1.0.dev10}/tests/test_models_are_current.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|