AssertionError: Bad state transition from EXPIRED to DEACTIVATED
Bug #641266 reported by
Curtis Hovey
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Launchpad itself |
Fix Released
|
High
|
j.c.sackett |
Bug Description
OOPS-1720EC636 is a bad API request. The AssertionError should be exported so that the user knows why his script is bad.
Related branches
lp://staging/~jcsackett/launchpad/bad-state-transition-641266
- Graham Binns (community): Approve (code)
-
Diff: 151 lines (+100/-6)4 files modifiedlib/canonical/launchpad/interfaces/__init__.py (+1/-0)
lib/lp/registry/errors.py (+20/-0)
lib/lp/registry/model/teammembership.py (+11/-6)
lib/lp/registry/tests/test_teammembership_webservice.py (+68/-0)
Changed in launchpad-registry: | |
milestone: | series-future → 10.10 |
Changed in launchpad-registry: | |
assignee: | nobody → j.c.sackett (jcsackett) |
status: | Triaged → In Progress |
tags: |
added: qa-ok removed: qa-needstesting |
Changed in launchpad-registry: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
There are two assertions. I think we want to revise the code to explicitly raise an ValueError type because the status is not valid for the current state. We wrap the error in expose() so that the API user can see the message. This might be the way to do this.
lp.registry.errors: declarations import webservice_error ransitionError( ValueError) : error(406)
from lazr.restful.
class TeamMembershipT
# HTTP Error: 'Not acceptable'
webservice_
lp.registry. model.teammembe rship:
from lazr.restful.error import expose
if self.status not in state_transition: TeamMembershipT ransitionError(
"Unknown status: %s" % self.status.name)) n[self. status] : TeamMembershipT ransitionError(
"Bad state transition from %s to %s"
raise expose(
if status not in state_transitio
raise expose(
% (self.status.name, status.name))