HKUDS/DeepTutor · error · ValueError

Knowledge base ' ' already uses that MarginNote store. Pick…

Error message

Knowledge base '{claimed_by}' already uses that MarginNote store. Pick a name that differs by more than punctuation.

What it means

Punctuation-fold uniqueness guard in register_marginnote4_kb: another KB already claims the same MarginNote store db_path after name normalization (the 'differs by more than punctuation' rule), preventing two KB names from shadowing one MarginNote library.

Solutions

  1. Reuse the existing KB that owns this MarginNote store
  2. Pick a genuinely different KB name (not just punctuation/case changes)
  3. Point db_path at a different MarginNote export if a separate KB is truly needed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at deeptutor/knowledge/manager.py:929 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/3d867c87a1ba8f08. Report an issue: GitHub.

Appendix: source

Thrown at deeptutor/knowledge/manager.py:929

        claimed by another library.
        """
        name = (name or "").strip()
        if not name:
            raise ValueError("Knowledge base name is required.")

        self.config = self._load_config()
        knowledge_bases = self.config.setdefault("knowledge_bases", {})
        if name in knowledge_bases:
            raise ValueError(f"A knowledge base named '{name}' already exists.")

        db_path = (db_path or "").strip()
        claimed_by = self._marginnote4_store_owner(name, db_path, knowledge_bases)
        if claimed_by:
            # Distinct names can still derive one store: the default path keeps
            # only alphanumerics, `-` and `_`, so "My Lib" and "My/Lib" both
            # land on My_Lib.db. Sharing it would merge two libraries' objects
            # and let either one's devices sync into the other.
            raise ValueError(
                f"Knowledge base '{claimed_by}' already uses that MarginNote store. "
                "Pick a name that differs by more than punctuation."
            )

        now = datetime.now().isoformat()
        entry: dict[str, Any] = {
            "path": name,
            "type": MARGINNOTE4_KB_TYPE,
            "description": description or f"MarginNote 4 library: {name}",
            "status": "ready",
            "needs_reindex": False,
            "created_at": now,
            "updated_at": now,
        }
        if db_path:
            entry["db_path"] = db_path
        knowledge_bases[name] = entry
        self._save_config()

View on GitHub (pinned to 3e82f13042)