API: IntegrityError when trying to create a newTask to a bug that already has one for that project

Bug #345904 reported by Ursula Junque
2
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Critical
Unassigned

Bug Description

Using the API, when I try to addTask on a bug that already has a task for that project, it oopses like OOPS-1174S4:

  IntegrityError: duplicate key value violates unique constraint "bugtask__product__bug__key"

It would be nice to have a proper error instead of this oops.

Tags: api lp-bugs oops
Ursula Junque (ursinha)
tags: added: api oops
Revision history for this message
Eleanor Berger (intellectronica) wrote :

The error message could be a bit better, but other than that there's not much we can improve.

Changed in malone:
importance: Undecided → Low
status: New → Triaged
Changed in launchpad:
importance: Low → Critical
Revision history for this message
Leonard Richardson (leonardr) wrote :

On the website, the target of the new bugtask is validated with valid_upstreamtask(). This happens in ChooseProductStep.validateStep. Since the validation code is in the view, not the model, it's not run when the same thing happens on the web service. Move the validation code into the model (this is the part I don't know how to do) and use webservice_error() or expose() on the exception raised when this error occurs.

Revision history for this message
Robert Collins (lifeless) wrote :

I think leonard may already have fixed this.

Revision history for this message
Leonard Richardson (leonardr) wrote :

Verified that this now results in a 400 Bad Request:

LaunchpadValidationError: A fix for this bug has already been requested for launchpadlib

Changed in launchpad:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.