diff --git a/esphome/platformio/library.py b/esphome/platformio/library.py index 049d4f3b87..999b1d3f11 100644 --- a/esphome/platformio/library.py +++ b/esphome/platformio/library.py @@ -994,7 +994,10 @@ def convert_libraries( dep_name = dependency.get("name") if ( isinstance(dep_name, str) - and _node_key(dep_name, None, None)[0] in nodes + # _node_key raises for a malformed URL-ish name; that + # entry belongs to the warning below, not a traceback + and "://" not in dep_name + and _node_key(dep_name, None, None)[0] in top_level_keys ): # Already requested top-level: present in the build, not # a drop (a false warning teaches users to ignore the diff --git a/tests/unit_tests/test_platformio_library.py b/tests/unit_tests/test_platformio_library.py index 8202658675..4b5b4508a0 100644 --- a/tests/unit_tests/test_platformio_library.py +++ b/tests/unit_tests/test_platformio_library.py @@ -665,3 +665,17 @@ def test_versionless_dependency_requested_top_level_stays_quiet( _backend(), ) assert "has no version to resolve" not in caplog.text + + +def test_versionless_url_ish_dependency_name_warns_cleanly( + tmp_path, monkeypatch, caplog: pytest.LogCaptureFixture +) -> None: + """A malformed URL-ish dependency name falls to the drop warning, never + a RuntimeError out of the key parser.""" + _patch_download_with_manifests( + monkeypatch, + tmp_path, + {"esphome/A": {"name": "A", "dependencies": [{"name": "file://"}]}}, + ) + convert_libraries([Library("esphome/A", None, None)], _backend()) + assert "'file://' of esphome/A has no version to resolve" in caplog.text