Issue 1:
The body of a chord can be a task, a chain of tasks, or a group of tasks. In all of these cases, as expected, the result of the chord's header is passed to the body. However, if the body of a chord contains one or more chains, the return value of the chord's header is suddenly gone!

Example application: canvastest.py

#!/usr/bin/env python
from celery import Celery

__all__ = ('app', 'ident')

app = Celery('canvastest.py', backend='redis://')

@app.task
def i(x):
return x

if __name__ == '__main__':
app.start()

Start the worker

$ ./canvastest.py worker

What works

The body of a chord can be a task, a chain of tasks, or a group of tasks. These all give the expected results:

$ ./canvastest.py shell --python
>>> chord([i.s(1), i.s(2)])(i.s()).get(timeout=5)
[1, 2]
>>> chord([i.s(1), i.s(2)])(i.s() | i.s()).get(timeout=5)
[1, 2]
>>> chord([i.s(1), i.s(2)])(group(i.s(), i.s())).get(timeout=5)
[[1, 2], [1, 2]]

What's broken

It breaks if the body of the chord is a group that contains one or more chains. For some reason the result of the chord's header is lost.

>>> chord([i.s(1), i.s(2)])(group(i.s() | i.s(), i.s())).get(timeout=5)
...
TimeoutError: The operation timed out.

Here is the error message from the worker:

[2017-07-25 22:16:31,904: ERROR/ForkPoolWorker-3] Chord callback for '769854f7-bda9-4fa4-a496-b0e03809c5fd' raised: TypeError('i() takes exactly 1 argument (0 given)',)
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celery/backends/redis.py", line 290, in on_chord_part_return
callback.delay([unpack(tup, decode) for tup in resl])
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celery/canvas.py", line 182, in delay
return self.apply_async(partial_args, partial_kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celery/canvas.py", line 986, in apply_async
args=args, kwargs=kwargs, **options))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celery/canvas.py", line 1062, in _apply_tasks
**options)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celery/canvas.py", line 566, in apply_async
dict(self.options, **options) if options else self.options))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celery/canvas.py", line 596, in run
first_task.apply_async(**options)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celery/canvas.py", line 221, in apply_async
return _apply(args, kwargs, **options)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celery/app/task.py", line 518, in apply_async
check_arguments(*(args or ()), **(kwargs or {}))
TypeError: i() takes exactly 1 argument (0 given)

Issue 2:
In the Documentations says:

Groups and chords accepts partial arguments too, so in a chain the return value of the previous task is forwarded to all tasks in the group...

but it doesn't if group contain chain.

Steps to reproduce

# ct.py
from __future__ import absolute_import, unicode_literals
from celery import Celery

app = Celery(
'ct',
broker='amqp://guest@localhost//',
backend='cache+memcached://127.0.0.1:11211/'
)

@app.task
def inc(x):
x += 1
return x

@app.task
def nothing(x):
return x

if __name__ == '__main__':
app.start()

Start worker:

python ct.py worker -l info

In python console:

>>> from ct import inc, nothing
>>> from celery import group, chain
>>> t = chain(inc.s(),group(chain(nothing.s(), inc.s()), inc.s()))
>>> r = t.delay(0)
>>>

In celery log:

[2017-04-10 12:43:36,126: INFO/MainProcess] Received task: ct.inc[5c1beeff-d785-4d81-af2c-35a5bba839ab]
[2017-04-10 12:43:37,257: WARNING/PoolWorker-1] /home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/app/trace.py:542: RuntimeWarning: Exception raised outside body: TypeError('nothing() takes exactly 1 argument (0 given)',):
Traceback (most recent call last):
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/app/trace.py", line 424, in trace_task
parent_id=uuid, root_id=root_id,
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/canvas.py", line 987, in apply_async
args=args, kwargs=kwargs, **options))
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/canvas.py", line 1063, in _apply_tasks
**options)
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/canvas.py", line 567, in apply_async
dict(self.options, **options) if options else self.options))
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/canvas.py", line 597, in run
first_task.apply_async(**options)
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/canvas.py", line 221, in apply_async
return _apply(args, kwargs, **options)
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/app/task.py", line 518, in apply_async
check_arguments(*(args or ()), **(kwargs or {}))
TypeError: nothing() takes exactly 1 argument (0 given)

exc, exc_info.traceback)))
[2017-04-10 12:43:37,262: ERROR/PoolWorker-1] Task ct.inc[5c1beeff-d785-4d81-af2c-35a5bba839ab] raised unexpected: TypeError('nothing() takes exactly 1 argument (0 given)',)
Traceback (most recent call last):
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/app/trace.py", line 424, in trace_task
parent_id=uuid, root_id=root_id,
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/canvas.py", line 987, in apply_async
args=args, kwargs=kwargs, **options))
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/canvas.py", line 1063, in _apply_tasks
**options)
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/canvas.py", line 567, in apply_async
dict(self.options, **options) if options else self.options))
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/canvas.py", line 597, in run
first_task.apply_async(**options)
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/canvas.py", line 221, in apply_async
return _apply(args, kwargs, **options)
File "/home/vagrant/ct-env/local/lib/python2.7/site-packages/celery/app/task.py", line 518, in apply_async
check_arguments(*(args or ()), **(kwargs or {}))
TypeError: nothing() takes exactly 1 argument (0 given)

Expecting result

>>> r.get()
[2, 2]

Celery info

celery -A ct report

software -> celery:4.0.2 (latentcall) kombu:4.0.2 py:2.7.9
billiard:3.5.0.2 py-amqp:2.1.4
platform -> system:Linux arch:64bit, ELF imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:amqp results:cache+memcached://127.0.0.1:11211/

broker_url: u'amqp://guest:********@localhost:5672//'
result_backend: u'cache+memcached://127.0.0.1:11211/'

Notes

Work fine with Celery 3.x