Bug 1309468

Summary: UnboundLocalError: local variable 'primif' referenced before assignment
Product: [Community] Spacewalk Reporter: W. Andrew Denton <bugzilla.redhat>
Component: ServerAssignee: Tomáš Kašpárek <tkasparek>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 2.4   
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-06-16 07:52:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1484117    

Description W. Andrew Denton 2016-02-17 22:05:03 UTC
Description of problem:
Registering a certain system causes 500 Internal Server error. This appears to be due to an interface on the client system that has no IP address.

Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/spacewalk/server/apacheRequest.py", line 129, in call_function
    response = func(*params)
  File "/usr/share/rhn/server/handlers/xmlrpc/registration.py", line 1030, in add_hw_profile
    if primif:
UnboundLocalError: local variable 'primif' referenced before assignment


Version-Release number of selected component (if applicable):
spacewalk-backend-xmlrpc-2.4.23-1.el6.noarch


How reproducible:
Always

This change fixes the problem for me:

--- /usr/share/rhn/server/handlers/xmlrpc/registration.py.orig	2016-02-17 14:02:46.742891028 -0800
+++ /usr/share/rhn/server/handlers/xmlrpc/registration.py	2016-02-17 13:40:28.343527458 -0800
@@ -1011,6 +1011,7 @@
         if row:
             ipaddr=row['ipaddr']
             ip6addr=row['ip6addr']
+            primif = None
             if ipaddr:
                 h = rhnSQL.prepare("""
                     select interface_id from rhnServerNetAddress4 where address = :address

Comment 1 Tomáš Kašpárek 2016-03-10 12:57:58 UTC
spacewalk.git(master):
2ac5a69c7f3a5c3034223f7bdf7914557846b082

Comment 2 Tomáš Kašpárek 2016-06-16 07:52:43 UTC
Spacewalk 2.5 was released.

Comment 3 Eric Herget 2017-09-28 18:11:14 UTC
This BZ closed some time during 2.5, 2.6 or 2.7.  Adding to 2.7 tracking bug.