{"record":{"id":"82950db788c581f9","repo":"langchain-ai/deepagents","slug":"name-must-be-a-table","errorCode":null,"errorMessage":"{name} must be a table","messagePattern":"(.+?) must be a table","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/model_config.py","lineNumber":4363,"sourceCode":"    \"\"\"Read-modify-write one entry in `[effort.by_model]`.\n\n    Args:\n        model_spec: Model in `provider:model` format.\n        effort: Reasoning effort label to save, or `None` to clear it.\n        config_path: Path to config file.\n\n    Returns:\n        `True` if the update succeeded, `False` if it failed.\n    \"\"\"\n    if config_path is None:\n        config_path = DEFAULT_CONFIG_PATH\n    if effort is None and not config_path.exists():\n        return True\n\n    def _require_table(value: object, name: str) -> dict:\n        if not isinstance(value, dict):\n            msg = f\"{name} must be a table\"\n            raise TypeError(msg)\n        return value\n\n    try:\n        with _config_write_lock:\n            config_path.parent.mkdir(parents=True, exist_ok=True)\n            if config_path.exists():\n                with config_path.open(\"rb\") as f:\n                    data = tomllib.load(f)\n            else:\n                data = {}\n\n            effort_section = _require_table(data.setdefault(\"effort\", {}), \"[effort]\")\n            by_model = _require_table(\n                effort_section.setdefault(\"by_model\", {}), \"[effort.by_model]\"\n            )\n\n            if effort is None:\n                if model_spec not in by_model:","sourceCodeStart":4345,"sourceCodeEnd":4381,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/model_config.py#L4345-L4381","documentation":"When writing the TOML config, _require_table validates that each top-level section being updated is a table (dict). If a parsed TOML value with the given name is a scalar/array instead of a table, it raises TypeError('{name} must be a table'). The library throws this to prevent corrupting a config where, say, `[startup]` was hand-edited into a plain string.","triggerScenarios":"Any config-saving path (e.g. saving startup/recent settings or sort order) when the existing config file defines the target section name as a non-table TOML value, such as `startup = \"auto\"` instead of `[startup]`.","commonSituations":"Manual hand-editing of config.toml with wrong syntax (key=value instead of a [section] header); a previous buggy writer or another tool flattened the section; copy-pasting a scalar over a section.","solutions":["Open the config file printed/located at config_path and rewrite the offending entry as a TOML table: `startup = \"auto\"` → `[startup]` with keys beneath it.","If the file is badly corrupted, back it up and delete/recreate it so the library regenerates a valid config.","Validate the TOML with a parser (`python -c \"import tomllib;print(tomllib.load(open('<path>','rb')))\"`) before saving again."],"exampleFix":"// before (invalid TOML section)\nstartup = \"auto\"\n// after\n[startup]\nrecent = \"auto\"","handlingStrategy":"validation","validationCode":"import tomllib\nwith open(config_path, \"rb\") as fh:\n    cfg = tomllib.load(fh)\nbad = [k for k, v in cfg.items() if k in {\"startup\"} and not isinstance(v, dict)]\nif bad:\n    raise SystemExit(f\"Config sections must be TOML tables, fix: {bad}\")","typeGuard":null,"tryCatchPattern":"try:\n    save_recent_startup_mode(mode)\nexcept TypeError:\n    # back up and let the library rebuild a valid config\n    config_path.rename(config_path.with_suffix(\".toml.bak\"))\n    save_recent_startup_mode(mode)","preventionTips":["Edit config.toml with TOML-aware editors; use [section] headers, not key=value scalars.","Validate TOML after manual edits before launching the app.","Never overwrite config sections with scalars in custom tooling."],"tags":["python","toml","config","type-error"],"backgroundTag":"invalid-config-format","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}