Bug 7284

Summary: Toaster managed mode: two or more variables having the same name can be added for the same project
Product: [Build System, Metadata & Runtime] Toaster Reporter: Ionut Chisanovici <ionutx.chisanovici>
Component: toasterAssignee: David Reyna <david.reyna>
Status: VERIFIED FIXED QA Contact: Alexandru Roman <alexandru.costinx.roman>
Severity: major    
Priority: Medium CC: alexandru.costinx.roman, alexandru.damian, belen.barros.pena, bluelightning, bogdanx.a.voiculescu, cristiana.voicu, jessica.zhang
Version: 1.8   
Target Milestone: 1.8 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: New (Never tested)
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
crashed_toaster_project_page
none
Design - Validating input none

Description Ionut Chisanovici 2015-02-04 13:49:04 UTC
Created attachment 2387 [details]
crashed_toaster_project_page

Hi,

For 1.8 M2 RC2, commit: 22c38e2d8a058619e3d05534b5e830b750aa4241, for a particular project, the configuration page ("Edit configuration variables") allow users to add two or more variables having the same name as the one that is already added.
This is causing toaster project configuration page to crash.

select name, value from orm_projectvariable;
 name = IMAGE_INSTALL_append
value = 

 name = PACKAGE_CLASSES
value = package_rpm

 name = MACHINE
value = genericx86-64

 name = SDKMACHINE
value = x86_64

 name = DISTRO
value = poky

 name = IMAGE_FSTYPES
value = ext3 jffs2 tar.bz2

 name = MACHINE
value = qemux86

Below the traceback from toaster_web.log:

Internal Server Error: /toastergui/project/1/
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/ionut/work/poky_1.8/poky/bitbake/lib/toaster/toastergui/views.py", line 2056, in project
    context["machine"] = {"name": prj.projectvariable_set.get(name="MACHINE").value}
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 143, in get
    return self.get_query_set().get(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 405, in get
    (self.model._meta.object_name, num, kwargs))
MultipleObjectsReturned: get() returned more than one ProjectVariable -- it returned 2! Lookup parameters were {'name': 'MACHINE'}
[04/Feb/2015 15:39:48] "GET /toastergui/project/1/ HTTP/1.1" 500 86331

Attached the screen shot with the crashed page.

Cheers,
Ionut C
Comment 1 Belen Barros Pena 2015-02-04 16:59:06 UTC
You should get an error when you try to add a variable that is already set in the page. See attached design document.
Comment 2 Belen Barros Pena 2015-02-04 16:59:29 UTC
Created attachment 2389 [details]
Design - Validating input
Comment 3 Belen Barros Pena 2015-02-18 11:26:28 UTC
This is addressed by the fix submitted for bug 7231
Comment 4 Ionut Chisanovici 2015-02-26 15:01:25 UTC
Also appears in 1.8._M3.RC1, commit: 40d80f9e019118ac7bcd268f21e350bc154a4a63

Cheers,
Ionut C
Comment 5 Alexandru Roman 2015-12-03 15:41:23 UTC
Verified.