From 8058a7c158e9ce1c048c207136827f80c1ec0ff9 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Tue, 7 Oct 2025 14:19:26 +0200 Subject: [PATCH] lib/instrospection: Skip either(oneOf) For either(oneOf) types, we skip introspection as we cannot determine which branch of the union was taken without more context This *should* be safe, as it can currently mostly be triggered through The `extraModules` setting of inventory modules. Example: ``` importer.roles.default.extraModules = [ ../../modules/nixos/common.nix ]; ``` Error Message: ``` Traceback (most recent call last): File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_lib/templates/handler.py", line 91, in machine_template yield dst_machine_dir File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_cli/machines/create.py", line 95, in create_machine inventory_store.write(inventory, message=f"machine '{machine_name}'") ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_lib/persist/inventory_store.py", line 269, in write write_info = self._write_map() File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_lib/persist/inventory_store.py", line 214, in _write_map current_priority = self._get_inventory_current_priority() File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_lib/persist/inventory_store.py", line 206, in _get_inventory_current_priority return self._flake.select("clanInternals.inventoryClass.introspection") ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_lib/flake/flake.py", line 1129, in select self.get_from_nix([selector]) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^ File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_lib/flake/flake.py", line 1054, in get_from_nix raise ClanSelectError( ...<3 lines>... ) from e clan_lib.flake.flake.ClanSelectError: Error on: $ clan select 'clanInternals.inventoryClass.introspection' Reason: Yet Unsupported type: either Removing left-over machine directory: /tmp/hyperconfig/machines/trooo Error on: $ clan select 'clanInternals.inventoryClass.introspection' Reason: Yet Unsupported type: either ``` Closes: #5387 --- lib/introspection/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/introspection/default.nix b/lib/introspection/default.nix index cf74c1bd5..9e8c39915 100644 --- a/lib/introspection/default.nix +++ b/lib/introspection/default.nix @@ -149,6 +149,13 @@ let # TODO: Add index support in nixpkgs first # else if type.name == "listOf" then # handleListOf meta.list + else if type.name == "either" then + # For either(oneOf) types, we skip introspection as we cannot + # determine which branch of the union was taken without more context + # This *should* be safe, as it can currently mostly be triggered through + # The `extraModules` setting of inventory modules and seems to be better + # than just aborting entirely. + { } else throw "Yet Unsupported type: ${type.name}"; in