cocoindex-io/cocoindex · error · ValueError
Specify either `db_settings=` or the legacy `lmdb_max_dbs=`/
Error message
Specify either `db_settings=` or the legacy `lmdb_max_dbs=`/`lmdb_map_size=` keyword arguments, not both.
What it means
Settings.__init__ rejects passing the new db_settings= object together with the legacy lmdb_max_dbs=/lmdb_map_size= keyword arguments, since the two mechanisms configure the same LMDB storage and are mutually exclusive. The legacy kwargs are kept only for backward compatibility.
Source
Thrown at python/cocoindex/_internal/setting.py:80
db_path: os.PathLike[str] | None
db_settings: LmdbSettings
# Deprecated v0 leftover; has no effect in v1. Kept (always `None`) so callers
# that still pass `global_execution_options=None` don't break.
global_execution_options: None
def __init__(
self,
db_path: os.PathLike[str] | None = None,
db_settings: LmdbSettings | None = None,
*,
lmdb_max_dbs: int | None = None,
lmdb_map_size: int | None = None,
global_execution_options: None = None, # Deprecated; ignored.
) -> None:
if db_settings is not None and (
lmdb_max_dbs is not None or lmdb_map_size is not None
):
raise ValueError(
"Specify either `db_settings=` or the legacy "
"`lmdb_max_dbs=`/`lmdb_map_size=` keyword arguments, not both."
)
if db_settings is None:
db_settings = LmdbSettings()
if lmdb_max_dbs is not None:
db_settings.max_dbs = lmdb_max_dbs
if lmdb_map_size is not None:
db_settings.map_size = lmdb_map_size
self.db_path = db_path
self.db_settings = db_settings
self.global_execution_options = None
@property
def lmdb_max_dbs(self) -> int:
return self.db_settings.max_dbs
View on GitHub (pinned to e84aa99b32)
Solutions
- Remove the legacy lmdb_max_dbs=/lmdb_map_size= kwargs and keep only db_settings=
- Or drop db_settings= and configure solely via the legacy kwargs if on old code
- Express the legacy values inside LmdbSettings(max_dbs=..., map_size=...) when consolidating
Example fix
// before Settings(db_settings=LmdbSettings(map_size=1 << 40), lmdb_max_dbs=64) // after Settings(db_settings=LmdbSettings(max_dbs=64, map_size=1 << 40))
Defensive patterns
Strategy: validation
Validate before calling
def build_settings(db_settings=None, lmdb_max_dbs=None, lmdb_map_size=None):
assert not (db_settings is not None and (lmdb_max_dbs is not None or lmdb_map_size is not None))
return Settings(db_settings=db_settings, lmdb_max_dbs=lmdb_max_dbs, lmdb_map_size=lmdb_map_size) Try / catch
try:
settings = Settings(db_settings=..., lmdb_max_dbs=...)
except ValueError as e:
settings = Settings(db_settings=LmdbSettings(max_dbs=..., map_size=...)) Prevention
- After migrating to db_settings=, delete all legacy kwargs
- Centralize Settings construction in one factory function
- Grep codebase for lmdb_max_dbs/lmdb_map_size when touching settings
When it happens
Trigger: Constructing Settings(db_settings=LmdbSettings(...), lmdb_max_dbs=N) or Settings(db_settings=..., lmdb_map_size=...) — any combination where db_settings is not None and either legacy kwarg is not None.
Common situations: Migrating code from the legacy kwargs to db_settings and leaving both in place; copying examples from old docs plus new docs; scaffolding tools that emit both forms.
Related errors
- Settings.db_path must be provided
- Environment settings must provide Settings.db_path (or set C
- {env_name} is not set
- failed to parse environment variable {env_name}: {value}
- report_to_stdout interval must be a positive duration
AI-assisted analysis of cocoindex-io/cocoindex@e84aa99b32 (2026-09-08).
Data as JSON: /api/errors/074d5bc2b9ca6b1b.
Report an issue: GitHub.