Bug 829767

Summary: JSON serialization broken in F17
Product: [Community] Gofer Reporter: Jeff Ortel <jortel>
Component: python-goferAssignee: Jeff Ortel <jortel>
Status: ON_QA --- QA Contact:
Severity: high Docs Contact:
Priority: unspecified    
Version: 0.66   
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jeff Ortel 2012-06-07 14:01:13 UTC
The json serialization is broken on F17.  In F17, simplejson jumped to version 2.5.2 (from 2.16 in F16).  In 2.5.2, support for collections.namedtuples is added which intruduces the problem.  The encode() detects namedtuples by doing hasattr(o, '_asdict') and them blindly call it without doing a callable() check.  The gofer Envelope object overrides __getattr__() so hasattr() is True but then encode() tries to call None.

This trace can be seen in agent.log:

2012-06-06 15:06:05,537 [ERROR][Actions] __call__() @ action.py:129 - 'NoneType' object is not callable
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/gofer/agent/action.py", line 127, in __call__
    self.target()
  File "/usr/lib64/gofer/plugins/pulpplugin.py", line 94, in heartbeat
    return self.send()
  File "/usr/lib64/gofer/plugins/pulpplugin.py", line 105, in send
    p.send(topic, ttl=delay, heartbeat=body)
  File "/usr/lib/python2.7/site-packages/gofer/messaging/producer.py", line 49, in send
    json = envelope.dump()
  File "/usr/lib/python2.7/site-packages/gofer/messaging/__init__.py", line 80, in dump
    return json.dumps(d, indent=2)
  File "/usr/lib64/python2.7/site-packages/simplejson/__init__.py", line 296, in dumps
    **kw).encode(obj)
  File "/usr/lib64/python2.7/site-packages/simplejson/encoder.py", line 228, in encode
    chunks = list(chunks)
  File "/usr/lib64/python2.7/site-packages/simplejson/encoder.py", line 509, in _iterencode
    for chunk in _iterencode_dict(o._asdict(), _current_indent_level):
TypeError: 'NoneType' object is not callable
2012-06-06 15:06:15,552 [ERROR][Actions] __call__() @ action.py:129 - 'NoneType' object is not callable
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/gofer/agent/action.py", line 127, in __call__
    self.target()
  File "/usr/lib64/gofer/plugins/pulpplugin.py", line 94, in heartbeat
    return self.send()
  File "/usr/lib64/gofer/plugins/pulpplugin.py", line 105, in send
    p.send(topic, ttl=delay, heartbeat=body)
  File "/usr/lib/python2.7/site-packages/gofer/messaging/producer.py", line 49, in send
    json = envelope.dump()
  File "/usr/lib/python2.7/site-packages/gofer/messaging/__init__.py", line 80, in dump
    return json.dumps(d, indent=2)
  File "/usr/lib64/python2.7/site-packages/simplejson/__init__.py", line 296, in dumps
    **kw).encode(obj)
  File "/usr/lib64/python2.7/site-packages/simplejson/encoder.py", line 228, in encode
    chunks = list(chunks)
  File "/usr/lib64/python2.7/site-packages/simplejson/encoder.py", line 509, in _iterencode
    for chunk in _iterencode_dict(o._asdict(), _current_indent_level):
TypeError: 'NoneType' object is not callable

Comment 1 Jeff Ortel 2012-06-08 20:43:19 UTC
Looks like this is fixed in simplejson 2.5.2.  In this version, it does a callable() check.

Comment 2 Jeff Ortel 2012-06-08 22:25:37 UTC
Fixed in gofer 0.69.

Also fixed in python-simplejson-2.5.2-1.fc17 available in F17 (updates).