Skip to content

Commit

Permalink
fix: do not fail import for invalid identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
motorina0 committed Jul 19, 2024
1 parent 3a4889f commit 9db00c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def validate_local_part(local_part: str):
regex = re.compile(r"^[a-z0-9_.]+$")
if not re.fullmatch(regex, local_part.lower()):
raise ValueError(
f"Identifier '{local_part}' not allowed! "
"Only a-z, 0-9 and .-_ are allowed characters, case insensitive."
)

Expand Down
13 changes: 10 additions & 3 deletions services.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ async def reimburse_payment(payment: Payment):

async def update_identifiers(identifiers: List[str], bucket: int):
for identifier in identifiers:
await update_identifier(identifier, bucket)
try:
await update_identifier(identifier, bucket)
except Exception as exc:
logger.warning(exc)


async def update_identifier(identifier, bucket):
Expand Down Expand Up @@ -294,5 +297,9 @@ async def refresh_bucket(
resp.raise_for_status()

for identifier in resp.text.split("\n"):
identifier_name = identifier.split(".")[0]
await update_identifier(identifier_name, bucket)
try:
identifier_name = identifier.split(".")[0]
await update_identifier(identifier_name, bucket)
await update_identifier(identifier, bucket)
except Exception as exc:
logger.warning(exc)

0 comments on commit 9db00c5

Please sign in to comment.