Skip to content

feat: Add PUT endpoint for products and related tests#12

Merged
mtruj013 merged 1 commit into
mainfrom
put-product-endpoint
Apr 9, 2026
Merged

feat: Add PUT endpoint for products and related tests#12
mtruj013 merged 1 commit into
mainfrom
put-product-endpoint

Conversation

@mtruj013
Copy link
Copy Markdown
Collaborator

@mtruj013 mtruj013 commented Apr 7, 2026

Done

  • Added PUT endpoint for products and related tests
  • Drive-by's:
    • Fixed redundant error on create_product_deployment
    • Refactored name normalisation logic into a shared NormalizeNameMixin

QA

  • See that tests pass
  • For a more thorough QA:
    • Run the site using the command dotrun
    • Add a couple deployments and see that everything passes as intended, sample curls here

Issue / Card

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

Comment thread webapp/views.py
db.session.remove()
return {
"error": {
"message": "Internal server error.",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: Probably better to print a specific error (which in this could be along the lines of "failed to update/save product", considering the single operation in the try block). Helps quick debugging and pinpointing the concerned block.

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.

Not sure I agree, 500s are by nature catch-alls for unexpected failures, so keeping the message generic is intentional. The specific error would be visible in server logs, which is the right place for debugging internals rather than exposing them in API responses (which could also turn into a security concern for server level issues)

Comment thread webapp/views.py
}
}, 404

product.name = name
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As slug will always remain the same despite the name, why is that desirable?

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.

Good question, it's an intentional decision for a couple reasons. Product name changes are extremely rare so any name/slug drift is equally rare and manageable, and slugs are used as path parameters across most endpoints, so regenerating them on name change would break any existing URLs, scripts, or integrations pointing at the old slug without giving the user any warning

@mtruj013 mtruj013 merged commit c5ba033 into main Apr 9, 2026
4 checks passed
@mtruj013 mtruj013 deleted the put-product-endpoint branch April 9, 2026 18:36
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