Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source S3: don't require history to be present to identify legacy state format #29520

Merged
merged 6 commits into from Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-s3/Dockerfile
Expand Up @@ -17,5 +17,5 @@ COPY source_s3 ./source_s3
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=3.1.7
LABEL io.airbyte.version=3.1.8
LABEL io.airbyte.name=airbyte/source-s3
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-s3/metadata.yaml
Expand Up @@ -5,7 +5,7 @@ data:
connectorSubtype: file
connectorType: source
definitionId: 69589781-7828-43c5-9f63-8925b1c1ccc2
dockerImageTag: 3.1.7
dockerImageTag: 3.1.8
dockerRepository: airbyte/source-s3
githubIssueLabel: source-s3
icon: s3.svg
Expand Down
Expand Up @@ -68,15 +68,17 @@ def _is_legacy_state(value: StreamState) -> bool:
return False
try:
# Verify datetime format in history
item = list(value.get("history", {}).keys())[0]
datetime.strptime(item, Cursor._DATE_FORMAT)
history = value.get("history", {}).keys()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Individually, _is_legacy_state is fine now but set_initial_state will raise ValueError because _convert_legacy_state will have an empty converted_history

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synced on this - this case shouldn't happen but we will handle it if it does.

if history:
item = list(value.get("history", {}).keys())[0]
datetime.strptime(item, Cursor._DATE_FORMAT)

# verify the format of the last_modified cursor
last_modified_at_cursor = value.get(DefaultFileBasedCursor.CURSOR_FIELD)
if not last_modified_at_cursor:
return False
datetime.strptime(last_modified_at_cursor, Cursor._LEGACY_DATE_TIME_FORMAT)
except (IndexError, ValueError):
except ValueError:
return False
return True

Expand Down
Expand Up @@ -406,7 +406,7 @@ def test_list_files_v4_migration(input_state, all_files, expected_files_to_sync,
id="legacy_state_with_invalid_last_modified_datetime_format_is_not_legacy",
),
pytest.param(
{"_ab_source_file_last_modified": "2023-08-01T00:00:00Z"}, False, id="legacy_state_without_history_is_not_legacy_state"
{"_ab_source_file_last_modified": "2023-08-01T00:00:00Z"}, True, id="legacy_state_without_history_is_legacy_state"
),
pytest.param({"history": {"2023-08-01": ["file1.txt"]}}, False, id="legacy_state_without_last_modified_cursor_is_not_legacy_state"),
pytest.param(
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/s3.md
Expand Up @@ -282,6 +282,7 @@ Be cautious when raising this value too high, as it may result in Out Of Memory

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:----------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------|
| 3.1.8 | 2023-08-17 | [29520](https://github.com/airbytehq/airbyte/pull/29520) | Update legacy state and error handling |
| 3.1.7 | 2023-08-17 | [29505](https://github.com/airbytehq/airbyte/pull/29505) | v4 StreamReader and Cursor fixes |
| 3.1.6 | 2023-08-16 | [29480](https://github.com/airbytehq/airbyte/pull/29480) | update Pyarrow to version 12.0.1 |
| 3.1.5 | 2023-08-15 | [29418](https://github.com/airbytehq/airbyte/pull/29418) | Avoid duplicate syncs when migrating from v3 to v4 |
Expand Down