Skip to content

backend.get_task_meta ignores the result_extended config parameter in mongodb backend #8387

@ycc140

Description

@ycc140

Checklist

  • I have verified that the issue exists against the main branch of Celery.
  • This has already been asked to the discussions forum first.
  • I have read the relevant section in the
    contribution guide
    on reporting bugs.
  • I have checked the issues list
    for similar or identical bug reports.
  • I have checked the pull requests list
    for existing proposed fixes.
  • I have checked the commit log
    to find out if the bug was already fixed in the main branch.
  • I have included all related issues and possible duplicate issues
    in this issue (If there are none, check this box anyway).

【version】
celery 5.3.1

【bug info】
When you set the result_extended config parameter to True extra task meta data is stored in the backend.
But when you call backend.get_task_meta those extra meta data values are not returned. The code is ignorant of the config parameter.

I looked at which extra meta data that is saved, and the awareness of the config parameter in backends.base._get_result_meta method and applied the same logic to the backends.mongodb._get_task_meta_for method, like this:

def _get_task_meta_for(self, task_id):
    """Get task meta-data for a task by id."""
    obj = self.collection.find_one({'_id': task_id})
    if obj:
        if self.app.conf.find_value_for_key('extended', 'result'):
            return self.meta_from_decoded({
            'name': obj['name'],
            'args': obj['args'],
            'task_id': obj['_id'],
            'queue': obj['queue'],
            'kwargs': obj['kwargs'],
            'status': obj['status'],
            'worker': obj['worker'],
            'retries': obj['retries'],
            'children': obj['children'],
            'date_done': obj['date_done'],
            'traceback': obj['traceback'],
            'result': self.decode(obj['result']),
        })
        return self.meta_from_decoded({
            'task_id': obj['_id'],
            'status': obj['status'],
            'result': self.decode(obj['result']),
            'date_done': obj['date_done'],
            'traceback': obj['traceback'],
            'children': obj['children'],
        })
    return {'status': states.PENDING, 'result': None}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions