{"record":{"id":"7ab04583655a9486","repo":"calesthio/OpenMontage","slug":"no-stock-source-registered-with-name-name-r","errorCode":null,"errorMessage":"No stock source registered with name={name!r}","messagePattern":"No stock source registered with name=(.+?)","errorType":"validation","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"tools/video/stock_sources/__init__.py","lineNumber":139,"sourceCode":"    return {\n        \"configured\": len(available),\n        \"total\": len(catalog),\n        \"available_source_names\": available,\n        \"unavailable_source_names\": unavailable,\n    }\n\n\ndef get_source(name: str) -> StockSource:\n    \"\"\"Look up a single adapter by its `name` attribute.\n\n    Raises `KeyError` if no registered adapter claims that name. Useful\n    for tests and for agents that want to pin to a specific source\n    (e.g. \"only Archive.org for this topic\").\n    \"\"\"\n    for s in all_sources():\n        if s.name == name:\n            return s\n    raise KeyError(f\"No stock source registered with name={name!r}\")\n","sourceCodeStart":121,"sourceCodeEnd":140,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/stock_sources/__init__.py#L121-L140","documentation":"KeyError raised by tools/video/stock_sources.get_source(name) when no registered adapter's .name attribute equals the requested name. The registry is built from all_sources(), which imports the adapter modules — so a typo, a disabled/failed import, or a name that was renamed yields this error rather than None (fail-fast lookup by contract).","triggerScenarios":"Calling get_source('archive') instead of 'archive_org', using an old name after an adapter rename, or referencing an adapter whose module failed to import at package load (e.g. missing optional dependency like beautifulsoup4 suppressing registration).","commonSituations":"Hardcoded source names in user config or agent prompts drifting from actual adapter names; forks that removed an adapter but kept config referencing it.","solutions":["List valid names first: [s.name for s in all_sources()] and use one of those exactly.","Check for import errors in the adapter modules — a silently failed import removes the source from the registry.","If the name lives in user config, validate it at config-load time against all_sources()."],"exampleFix":"# before\nsource = get_source(\"archive\")\n\n# after\nfrom tools.video.stock_sources import all_sources\nvalid = {s.name for s in all_sources()}\nsource = get_source(name if name in valid else \"archive_org\")","handlingStrategy":"validation","validationCode":"from tools.video.stock_sources import all_sources\nvalid_names = {s.name for s in all_sources()}\nif name not in valid_names:\n    raise ConfigError(f\"unknown stock source {name!r}; valid: {sorted(valid_names)}\")","typeGuard":"def is_registered_source(name: str) -> bool:\n    from tools.video.stock_sources import all_sources\n    return any(s.name == name for s in all_sources())","tryCatchPattern":"try:\n    source = get_source(name)\nexcept KeyError:\n    source = get_source(\"archive_org\")  # deterministic fallback","preventionTips":["Validate configured source names against all_sources() at startup.","Watch for import failures in adapter modules that silently shrink the registry."],"tags":["stock-footage","registry","lookup","config"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}