Skip to content

[Bug] CouchbaseBackend.mget() is incompatible with couchbase SDK >= 4 (get_multi returns MultiGetResult) #10694

Closed

Description

@simpleqt

Summary

CouchbaseBackend.mget() is still written against the couchbase SDK 3.x API. On couchbase >= 4.0 (verified against 4.6.3), collection.get_multi() returns a couchbase.result.MultiGetResult object instead of a list of values, and per-key failures are collected on that object instead of being raised. mget() passes that object straight through:

https://github.com/celery/celery/blob/main/celery/backends/couchbase.py#L121-L122

KeyValueStoreBackend._mget_to_results() (celery/backends/base.py) then fails on both of its branches:

  • MultiGetResult has no .items() (public surface is all_ok / exceptions / results), so the dict branch is skipped;
  • MultiResult defines no __iter__, so the list branch's enumerate(values) raises TypeError: 'MultiGetResult' object is not iterable.

Additionally, with return_exceptions semantics, keys whose documents are missing surface as DocumentNotFoundException entries in results/exceptions rather than as None — the KeyValueStoreBackend contract (get() → None for absent keys) is not honoured for the multi path either.

Impact

Reproduce

import inspect
from couchbase.result import MultiGetResult
print([a for a in dir(MultiGetResult) if not a.startswith('_')])  # ['all_ok', 'exceptions', 'results']
print(hasattr(MultiGetResult, 'items'), hasattr(MultiGetResult, '__iter__'))  # False False

then any get_many() against a CouchbaseBackend on couchbase 4.6.3 raises TypeError inside _mget_to_results.

Possible direction

Implement mget() against collection.get_multi(keys, return_exceptions=True) and translate the MultiGetResult.results mapping: successful GetResult → .content, per-key DocumentNotFoundException → None (matching the KV contract), other per-key exceptions → re-raise. The dict-shaped result can then be handed to _mget_to_results()'s existing dict branch (full celery-task-meta keys map through values.items()).

Found during review of #10680 (point 2, @MehrazRumman); verified against couchbase SDK 4.6.3 on celery main.

Activity

  1. modified the milestones: 5.7.0, 5.7.x on Sep 22, 2026
  2. auvipy commented on Sep 22, 2026

    @auvipy
    Member

    @simpleqt can you fix it?

  3. added a commit that references this issue on Sep 22, 2026
    988d372
  4. simpleqt commented on Sep 22, 2026

    @simpleqt
    Author
  5. auvipy commented on Sep 22, 2026

    @auvipy
    Member

    thanks a lot!

  6. modified the milestones: 5.7.x, 5.7.0 on Sep 22, 2026
  7. added a commit that references this issue on Sep 22, 2026
    1700781
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions