{"record":{"id":"edba53cb2e73eb55","repo":"headroomlabs-ai/headroom","slug":"default-importance-must-be-0-0-1-0-got-self-defa","errorCode":null,"errorMessage":"default_importance must be 0.0-1.0, got {self.default_importance}","messagePattern":"default_importance must be 0\\.0-1\\.0, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"headroom/memory/bridge_config.py","lineNumber":64,"sourceCode":"    md_format: MarkdownFormat = MarkdownFormat.AUTO\n    user_id: str = \"default\"\n    default_importance: float = 0.6\n    heading_importance_map: dict[int, float] = field(\n        default_factory=lambda: {1: 0.9, 2: 0.8, 3: 0.7, 4: 0.6, 5: 0.5, 6: 0.4}\n    )\n    sync_state_path: Path = field(default_factory=_paths.bridge_state_path)\n    auto_import_on_startup: bool = False\n    export_path: Path | None = None\n    export_format: MarkdownFormat = MarkdownFormat.GENERIC\n    extract_entities: bool = True\n    chunk_by_section: bool = True\n    dedup_similarity_threshold: float = 0.92\n    source_tag: str = \"memory_bridge\"\n\n    def __post_init__(self) -> None:\n        \"\"\"Validate configuration.\"\"\"\n        if not 0.0 <= self.default_importance <= 1.0:\n            raise ValueError(f\"default_importance must be 0.0-1.0, got {self.default_importance}\")\n        if not 0.0 <= self.dedup_similarity_threshold <= 1.0:\n            raise ValueError(\n                f\"dedup_similarity_threshold must be 0.0-1.0, got {self.dedup_similarity_threshold}\"\n            )\n        self.md_paths = [Path(p) if isinstance(p, str) else p for p in self.md_paths]\n        if isinstance(self.sync_state_path, str):\n            self.sync_state_path = Path(self.sync_state_path)\n        if self.export_path and isinstance(self.export_path, str):\n            self.export_path = Path(self.export_path)\n","sourceCodeStart":46,"sourceCodeEnd":74,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/memory/bridge_config.py#L46-L74","documentation":"ValueError raised in MemoryBridgeConfig.__post_init__ when default_importance is outside [0.0, 1.0]. The bridge assigns this importance to imported memories, and the rest of the memory system treats importance as a normalized float, so out-of-range values are rejected at config construction time.","triggerScenarios":"MemoryBridgeConfig(default_importance=5), default_importance=-0.1, or a value parsed from YAML/CLI as a string like 'high' that coerces unexpectedly; the dataclass __post_init__ runs immediately on construction.","commonSituations":"Copy-pasting a 1-10 importance scale from another tool; percentage (75) instead of fraction (0.75); config files shared between components with different ranges.","solutions":["Use a fraction in [0.0, 1.0], e.g. default_importance=0.75","If your config uses 1-10, convert before constructing: default_importance=raw / 10.0","Add a unit check where the config value originates (YAML/CLI parser) so bad values fail with clearer context"],"exampleFix":"# before\ncfg = MemoryBridgeConfig(default_importance=75)  # ValueError: must be 0.0-1.0\n\n# after\ncfg = MemoryBridgeConfig(default_importance=0.75)","handlingStrategy":"validation","validationCode":"def clamp_fraction(name: str, value: float) -> float:\n    if not 0.0 <= value <= 1.0:\n        raise ValueError(f'{name} must be in [0,1], got {value}')\n    return value\n\ncfg = MemoryBridgeConfig(\n    default_importance=clamp_fraction('default_importance', raw_importance),\n)","typeGuard":"def is_valid_importance(v) -> bool:\n    return isinstance(v, (int, float)) and not isinstance(v, bool) and 0.0 <= v <= 1.0","tryCatchPattern":"try:\n    cfg = MemoryBridgeConfig(default_importance=raw)\nexcept ValueError as e:\n    logger.error('bridge config invalid: %s', e)\n    cfg = MemoryBridgeConfig()  # fall back to defaults","preventionTips":["Document the 0-1 scale next to every importance config field","Validate external config (YAML/CLI) with range checks before constructing the dataclass","Convert percent-style inputs at the boundary: value / 100.0"],"tags":["python","config","validation","range-check","importance","memory-bridge"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}