Skip to content

feat: Add DEL endpoint for deployments and related tests#18

Merged
mtruj013 merged 2 commits into
mainfrom
delete-deployment-endpoint
Apr 24, 2026
Merged

feat: Add DEL endpoint for deployments and related tests#18
mtruj013 merged 2 commits into
mainfrom
delete-deployment-endpoint

Conversation

@mtruj013
Copy link
Copy Markdown
Collaborator

@mtruj013 mtruj013 commented Apr 22, 2026

Done

  • Added delete endpoint for deployments and related tests

QA

  • See that tests are passing
  • For a more thorough QA:
    • Run the site using the command dotrun
    • Delete a product and see that everything passes as intended, sample curls here

Issue / Card

https://warthogs.atlassian.net/browse/WD-35418

Copy link
Copy Markdown

@Onibenjo Onibenjo left a comment

Choose a reason for hiding this comment

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

some comments

Comment thread webapp/views.py
"reason": ("Products must have at least one deployment.")
},
}
}, 400
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
}, 400
}, 409

I believe a 409 better suits this case

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

409 is supposed to be resolvable if the client retries the request (eg server is receiving multiple requests to update the same resource). But this isn't resolvable because the user will never be able to delete the last deployment regardless of how they pass the request

Comment thread webapp/views.py
try:
db.session.commit()
except Exception:
db.session.remove()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
db.session.remove()
db.session.rollback()

Since the intent here is to discard the pending transaction after a failed commit()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The intent is correct, but this change would do the opposite. From sqlalchemy docs: "(scoped.session.remove)... releases any existing transactional/connection resources still being held; transactions specifically are rolled back."

Copy link
Copy Markdown

@Onibenjo Onibenjo left a comment

Choose a reason for hiding this comment

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

some additional comments

Comment thread webapp/views.py Outdated
Comment thread webapp/views.py
Comment thread webapp/views.py
}
}, 500

return {"deleted": deleted}, 200
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is this object needed?

Because for a successful deletion which is 204 No Content we should return "", 204 and remove the need for the deleted = {...} snapshot.

If we want the deleted representation instead, return DeploymentSchema().dump(deployment) (snapshotted before session.delete)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The users of auth protected endpoints (auth implementation blocked on prodstack status if wondering) will include product owners, the clear outputs using 200 are an intentional UX decision because of the intended audience (Stripe does something similar). The snapshot would include way more info than is actually needed so I'm not sure that it'd be much of an improvement.

More than happy to come back to this if after stakeholder feedback on this more complete version comes back that this isn't super needed, but for now I'd opt to keep as is.

@mtruj013 mtruj013 force-pushed the delete-deployment-endpoint branch from e234830 to ee53667 Compare April 24, 2026 15:27
@mtruj013 mtruj013 merged commit 3f57582 into main Apr 24, 2026
4 checks passed
@mtruj013 mtruj013 deleted the delete-deployment-endpoint branch April 24, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants