Edit branch details form need input validation for non-existent product

Bug #59249 reported by Diogo Matsubara
4
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
James Henstridge

Bug Description

Steps to reproduce (using sample date):
1. Logged in as Sample Person, open:
http://launchpad.dev/people/name12/+branch/+junk/junk.contrib/+edit
2. In 'Product' type in: foo (i.e. non-existent product);
3. Click 'Change branch';
3. Crash like: OOPS-248C572

Tags: lp-code oops
description: updated
Revision history for this message
James Henstridge (jamesh) wrote :

The validate() function for that form should be using data.get('product') rather than data['product'].

Since the data from the request didn't result in a valid product name, the product object doesn't get added to the data dictionary. The validate() method needs to cope with this.

Changed in launchpad-bazaar:
assignee: nobody → ddaa
Revision history for this message
David Allouche (ddaa) wrote :

Duh? I assumed that if the interface/vocabulary validation failed the view's validate() method would not be called.

Revision history for this message
David Allouche (ddaa) wrote :

Seems like a bad thing to require the validate method to cope with the absence of attributes. In addition it should not use data.get('product') because the None value (no product, junk branch) is perfectly valid here.

Revision history for this message
James Henstridge (jamesh) wrote :

There is a good reason to call the validate() method on field errors: we want to present all the validation errors to the user upfront, rather than have them fix the returned errors only to have new ones given on the next submission.

Using the branch edit form as an example, imagine that the user entered a value into the title field that caused a field validation error (e.g. they snuck in a new line character), and chose a branch name that was already in use. We'd want to display both errors to the user, which means invoking validate() even though we got a field validation error.

Revision history for this message
James Henstridge (jamesh) wrote :

Fix committed to rocketfuel as r4034

Changed in launchpad-bazaar:
assignee: ddaa → jamesh
status: Confirmed → Fix Committed
Revision history for this message
James Henstridge (jamesh) wrote :

This change was included in today's rollout.

Changed in launchpad-bazaar:
status: Fix Committed → 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.