Bug 13717 - FieldError when trying to load Reverse runtime dependencies
Summary: FieldError when trying to load Reverse runtime dependencies
Status: RESOLVED FIXED
Alias: None
Product: Toaster
Classification: Build System, Metadata & Runtime
Component: toaster (show other bugs)
Version: 2.6.4
Hardware: x86 Multiple
: Medium normal
Target Milestone: 3.1 M4
Assignee: David Reyna
QA Contact: Toaster default assignee
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2019-12-19 19:40 UTC by Ahmed Hossam
Modified: 2020-03-30 18:32 UTC (History)
0 users

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ahmed Hossam 2019-12-19 19:40:53 UTC
Preconditions/Environment
-------------------------
Poky branch thud
Ubuntu 18.04 LTS
command line build with toaster running

Triggering Action/Cause
-----------------------
git clone https://git.yoctoproject.org/git/poky -b thud --depth 1
cd poky/
source oe-init-build-env
# I added my common DL_DIR and SSTATE_DIR to conf/local.conf
source toaster start
bitbake core-image-minimal


Load up localhost:8000/
select the core image minimal from the command line builds
select core-image-minimal under images
select one of the included packages (For example busybox)
select the "Reverse runtime dependencies" tab
URL is http://localhost:8000/toastergui/build/3/package_included_reverse_dependencies/3/9196?count=25&page=1&orderby=package__name%3A%2B


Expectation
-----------
You should be able to see the reverse runtime dependencies

Actual Result
-------------
FieldError at /toastergui/build/3/package_included_reverse_dependencies/3/9196

Non-relational field given in select_related: 'name'. Choices are: build, recipe, customimagepackage

Request Method: 	GET
Request URL: 	http://localhost:8000/toastergui/build/3/package_included_reverse_dependencies/3/9196?count=25&page=1&orderby=package__name%3A%2B
Django Version: 	1.11.8
Exception Type: 	FieldError
Exception Value: 	

Non-relational field given in select_related: 'name'. Choices are: build, recipe, customimagepackage

Exception Location: 	/home/user/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py in get_related_selections, line 730
Python Executable: 	/usr/bin/python3
Python Version: 	3.6.9
Python Path: 	

['/ws/thud/poky/bitbake/lib',
 '/ws/thud/poky/bitbake/lib/toaster',
 '/usr/lib/python36.zip',
 '/usr/lib/python3.6',
 '/usr/lib/python3.6/lib-dynload',
 '/home/user/.local/lib/python3.6/site-packages',
 '/usr/local/lib/python3.6/dist-packages',
 '/usr/lib/python3/dist-packages']

Server time: 	Thu, 19 Dec 2019 20:20:56 +0100

#### Log truncated (Tell me if you need the full log) #### 

/ws/thud/poky/bitbake/lib/toaster/toastergui/views.py in package_included_reverse_dependencies

1216. for o in objects:

▼ Local vars
Variable 	Value
build_id 	'3'
filter_string 	''
mandatory_parameters 	{'count': '25', 'orderby': 'package__name:+', 'page': 1}
objects 	Error in formatting: FieldError: Non-relational field given in select_related: 'name'. Choices are: build, recipe, customimagepackage
orderby 	'package__name:+'
ordering_string 	'package__name:+'
package 	<Package: Package object>
package_id 	'9196'
pagesize 	'25'
queryset 	Error in formatting: FieldError: Non-relational field given in select_related: 'name'. Choices are: build, recipe, customimagepackage
request 	<WSGIRequest: GET '/toastergui/build/3/package_included_reverse_dependencies/3/9196?count=25&page=1&orderby=package__name%3A%2B'>
retval 	None
search_term 	''
target 	<Target: Target object>
target_id 	'3'
template 	'package_included_reverse_dependencies.html'

#### Log truncated (Tell me if you need the full log) #### 

Reproducibility
---------------
always (5/5)

Currently used workaround
-------------------------
# This workaround is from 10 minutes of googling with no knowledge about this API
# After the workaround is applied the command "source toaster stop" then "source toaster start" need to be executed
$ git diff
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index c712b06..5c1ce70 100644
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -1206,7 +1206,7 @@ def package_included_reverse_dependencies(request, build_id, target_id, package_
         return _redirect_parameters( 'package_included_reverse_dependencies', request.GET, mandatory_parameters, build_id = build_id, target_id = target_id, package_id = package_id)
     (filter_string, search_term, ordering_string) = _search_tuple(request, Package_File)
 
-    queryset = Package_Dependency.objects.select_related('depends_on__name', 'depends_on__size').filter(depends_on=package_id, target_id=target_id, dep_type=Package_Dependency.TYPE_TRDEPENDS)
+    queryset = Package_Dependency.objects.select_related('depends_on').filter(depends_on=package_id, target_id=target_id, dep_type=Package_Dependency.TYPE_TRDEPENDS)
     objects = _get_queryset(Package_Dependency, queryset, filter_string, search_term, ordering_string, 'package__name')
 
     package = Package.objects.get(pk=package_id)
Comment 1 Ahmed Hossam 2019-12-19 22:00:11 UTC
Reproduced on master with the same steps.
Comment 2 Ahmed Hossam 2019-12-19 23:08:42 UTC
Reproduced on Thud with project created from the Toaster GUI
Comment 3 David Reyna 2019-12-20 00:43:25 UTC
Interesting. You found a bug and provided a potential fix, thank you!

I will take a look. I am curious why I have not hit this error path.
Comment 4 Ahmed Hossam 2019-12-20 00:59:44 UTC
(In reply to comment #3)
> Interesting. You found a bug and provided a potential fix, thank you!
> 
> I will take a look. I am curious why I have not hit this error path.

I know this worked before in a previous release (Krogoth or Rocko) as I used Toaster for "Why is this file/package in my image?" investigations, not really sure when it broke.

Feel free to use the workaround/fix but keep in mind I had no idea what I was doing, just trying solutions to the error from stackoverflow until one of them worked, I don't know how removing that parameter and renaming the other "fixed" the issue.


Tell me if you need me to run any tests or trials, I will gladly do so.
Comment 5 David Reyna 2020-03-30 18:32:27 UTC
commit 4f959dff769f37d745daf705dd169704656e0ba3