Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ena-submission/src/ena_deposition/create_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
get_authors,
get_description,
get_ena_analysis_process,
retry_failed_submissions_for_matching_errors,
set_accession_does_not_exist_error,
trigger_retry_if_exists,
)
from .ena_types import (
DEFAULT_EMBL_PROPERTY_FIELDS,
Expand Down Expand Up @@ -758,12 +758,18 @@ def assembly_table_handle_errors(
)
messages.append(msg)

last_retry_time = trigger_retry_if_exists(
last_retry_time = retry_failed_submissions_for_matching_errors(
Copy link
Contributor

Choose a reason for hiding this comment

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

The FTP auth retry will loop indefinitely for persistent credential failures — only the retry_threshold_min cooldown limits frequency, but there's no max attempt count. This pattern already exists for the "does not exist in ENA" case, so it's not a new regression, but it means a persistent misconfiguration will keep retrying forever without alerting. The TODO on line 774 acknowledges this gap.

entries_with_errors,
db_config,
table_name=TableName.ASSEMBLY_TABLE,
retry_threshold_min=config.retry_threshold_min,
last_retry=last_retry_time,
error_substrings=(
Comment on lines 763 to +767
Copy link
Contributor

Choose a reason for hiding this comment

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

The first substring ends with "user error.:" — the trailing colon after the full stop looks unusual. Is this literally what ENA returns in the error message? If the colon is part of the actual message (e.g. preceding a stack trace), the match is fine, but it's worth confirming against a real example so the substring doesn't silently stop matching if ENA changes formatting.

"Submit service authentication error. Invalid submission account user "
"name or password. Please try enclosing your password in single quotes. "
"The submission has failed because of a user error.:",
"does not exist in ENA",
),
)
# TODO: Query ENA to check if assembly has in fact been created
# If created update assembly_table
Expand Down
4 changes: 2 additions & 2 deletions ena-submission/src/ena_deposition/create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
accession_exists,
create_ena_project,
get_alias,
retry_failed_submissions_for_matching_errors,
set_accession_does_not_exist_error,
trigger_retry_if_exists,
)
from .ena_types import (
OrganismType,
Expand Down Expand Up @@ -388,7 +388,7 @@ def project_table_handle_errors(
time=datetime.now(tz=pytz.utc),
slack_retry_threshold_min=config.slack_retry_threshold_min,
)
return trigger_retry_if_exists(
return retry_failed_submissions_for_matching_errors(
entries_with_errors,
db_config,
table_name=TableName.PROJECT_TABLE,
Expand Down
4 changes: 2 additions & 2 deletions ena-submission/src/ena_deposition/create_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
accession_exists,
create_ena_sample,
get_alias,
retry_failed_submissions_for_matching_errors,
set_accession_does_not_exist_error,
trigger_retry_if_exists,
)
from .ena_types import (
ProjectLink,
Expand Down Expand Up @@ -422,7 +422,7 @@ def sample_table_handle_errors(
time=datetime.now(tz=pytz.utc),
slack_retry_threshold_min=config.slack_retry_threshold_min,
)
last_retry_time = trigger_retry_if_exists(
last_retry_time = retry_failed_submissions_for_matching_errors(
entries_with_errors,
db_config,
table_name=TableName.SAMPLE_TABLE,
Expand Down
7 changes: 4 additions & 3 deletions ena-submission/src/ena_deposition/ena_submission_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,12 +878,12 @@ def set_accession_does_not_exist_error(
logger.warning(f"{accession_type} creation failed and DB update failed.")


def trigger_retry_if_exists(
def retry_failed_submissions_for_matching_errors(
entries_with_errors: Iterable[Mapping[str, Any]],
db_config: SimpleConnectionPool,
table_name: TableName,
retry_threshold_min: int,
error_substring: str = "does not exist in ENA",
error_substrings: Iterable[str] = ("does not exist in ENA",),
Copy link
Contributor

Choose a reason for hiding this comment

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

The type Iterable[str] is a subtle footgun here: a plain str is also Iterable[str], so passing "some error" accidentally instead of ("some error",) would silently iterate over individual characters. Consider narrowing to Sequence[str] or tuple[str, ...] to make the interface safer.

last_retry: datetime | None = None,
) -> datetime | None:
if (
Expand All @@ -892,7 +892,8 @@ def trigger_retry_if_exists(
):
return last_retry
for entry in entries_with_errors:
if error_substring not in str(entry.get("errors", "")):
errors = str(entry.get("errors", ""))
if not any(substring in errors for substring in error_substrings):
continue
match table_name:
case TableName.PROJECT_TABLE:
Expand Down
Loading