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

TileData.post catches all exceptions inside its transaction #11806

Open
jacobtylerwalls opened this issue Feb 21, 2025 · 0 comments
Open

TileData.post catches all exceptions inside its transaction #11806

jacobtylerwalls opened this issue Feb 21, 2025 · 0 comments
Labels
Type: Bug Something isn't working

Comments

@jacobtylerwalls
Copy link
Member

TileData.post looks like it uses a transaction to roll back failed writes, but it actually has no effect since all exceptions are caught inside its context.

Instead, we could let errors propagate and then transform them to a JSON response outside the transaction context manager.

with transaction.atomic():
try:
if accepted_provisional is None:
try:
tile.save(
request=request,
resource_creation=resource_creation,
transaction_id=transaction_id,
)
except TileValidationError as e:
resource_tiles_exist = (
models.TileModel.objects.filter(
resourceinstance=tile.resourceinstance
).exists()
)
if not resource_tiles_exist:
Resource.objects.get(
pk=tile.resourceinstance_id
).delete(request.user)
title = _(
"Unable to save. Please verify your input is valid"
)
return self.handle_save_error(
e, tile_id, title=title
)
except Exception as e:
title = _("Unable to save.")
return self.handle_save_error(
e, tile_id, title=title, message=str(e)
)

@jacobtylerwalls jacobtylerwalls added the Type: Bug Something isn't working label Feb 21, 2025
@chiatt chiatt added this to pipeline Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant