Repository: archlinux/archinstall

Issue:
"ValueError: Crypto luks cannot be set as a filesystem type" when attempting to delete crypto_LUKS partition
### Steps to reproduce

#### Prerequisite: create an installation with a crypto_LUKS partition
1. Run `archinstall`
1. Navigate to Disk configuration 
    1. Select `Use a best-effort default partition layout`
    1. Select the `/dev/sda` (or `/dev/vda`) entry and press enter
    1. Select `ext4`
1. Navigate to Disk encryption
    1. Select `Encryption password`
        1. Set a non-blank password
    1. Select `Partitions`
        1. Select the ext4 partition and press enter
    1. Select `<- Back`
1. Navigate to User account
    1. Select `Add a user`
        1. Enter a username and password
        1. Choose superuser permissions
    1. Select `Confirm and exit`
1. Select `Install`
    1. Press the enter key to continue
1. Wait for the installation to complete
1. Shut down the machine

#### Attempt to delete an existing crypto_LUKS partition during an installation
1. Boot the existing machine with the Arch .iso still attached
   1. Make sure to boot into the install medium
1. Run `archinstall`
1. Navigate to Disk configuration 
    1. Select `Manual Partitioning`
    1. Select the `/dev/sda` (or `/dev/vda`) entry and press enter
    1. Select the existing boot partition and press enter
       1. Select `Assign mountpoint`
       1. Enter `/boot` and press enter
    1. Select the existing crypto_LUKS partition and press enter
       1. Select `Delete partition`
    1. Select `Create a new partition`
       1. Select `ext4`
       1. Accept the default start value
       1. Accept the default end value
       1. Set the mountpoint to `/`
    1. Select `Confirm and exit`
1. Navigate to User account
    1. Select `Add a user`
        1. Enter a username and password
        1. Choose superuser permissions
    1. Select `Confirm and exit`
1. Select `Install`
    1. Press the enter key to continue

### Debugging
My assumption is that the installer is trying to prevent the creation of an opaque `crypto_LUKS` partition rather than prevent the deletion of one, but I may be misreading the code.

#### Log
[Full log](https://github.com/archlinux/archinstall/files/13971388/archinstall-luks-valueerror.log)

<details>

<summary>Disk configs</summary>

<pre>
 -- Chosen configuration --
{
    ...
    "disk_config": {
        "config_type": "manual_partitioning",
        "device_modifications": [
            {
                "device": "/dev/vda",
                "partitions": [
                    {
                        "btrfs": [],
                        "dev_path": "/dev/vda1",
                        "flags": [
                            "Boot"
                        ],
                        "fs_type": "fat32",
                        "mount_options": [],
                        "mountpoint": "/boot",
                        "obj_id": "9ae39016-55be-4783-a355-0f0138f224f6",
                        "size": {
                            "sector_size": {
                                "unit": "B",
                                "value": 512
                            },
                            "unit": "B",
                            "value": 212860928
                        },
                        "start": {
                            "sector_size": {
                                "unit": "B",
                                "value": 512
                            },
                            "unit": "sectors",
                            "value": 6144
                        },
                        "status": "existing",
                        "type": "primary"
                    },
                    {
                        "btrfs": [],
                        "dev_path": "/dev/vda2",
                        "flags": [],
                        "fs_type": "crypto_LUKS",
                        "mount_options": [],
                        "mountpoint": null,
                        "obj_id": "7a9c6cf7-7585-400c-8a9c-d1ed6afac5c7",
                        "size": {
                            "sector_size": {
                                "unit": "B",
                                "value": 512
                            },
                            "unit": "B",
                            "value": 21123563520
                        },
                        "start": {
                            "sector_size": {
                                "unit": "B",
                                "value": 512
                            },
                            "unit": "sectors",
                            "value": 522240
                        },
                        "status": "delete",
                        "type": "primary"
                    },
                    {
                        "btrfs": [],
                        "dev_path": null,
                        "flags": [],
                        "fs_type": "ext4",
                        "mount_options": [],
                        "mountpoint": "/",
                        "obj_id": "0f5f3eb1-8c9f-4929-a980-c21943c7fa41",
                        "size": {
                            "sector_size": {
                                "unit": "B",
                                "value": 512
                            },
                            "unit": "B",
                            "value": 83819008
                        },
                        "start": {
                            "sector_size": {
                                "unit": "B",
                                "value": 512
                            },
                            "unit": "sectors",
                            "value": 41779200
                        },
                        "status": "create",
                        "type": "primary"
                    }
                ],
                "wipe": false
            }
        ]
    },
    "disk_encryption": null,
   ...
</pre>

</details>

#### Backtrace
```
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/archinstall/__init__.py", line 329, in run_as_a_module
    main()
  File "/usr/lib/python3.11/site-packages/archinstall/__init__.py", line 324, in main
    importlib.import_module(mod_name)
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.11/site-packages/archinstall/scripts/guided.py", line 254, in <module>
    fs_handler.perform_filesystem_operations()
  File "/usr/lib/python3.11/site-packages/archinstall/lib/disk/filesystem.py", line 55, in perform_filesystem_operations
    device_handler.format(mod, enc_conf=self._enc_config)
  File "/usr/lib/python3.11/site-packages/archinstall/lib/disk/device_handler.py", line 302, in format
    self._validate_partitions(filtered_part)
  File "/usr/lib/python3.11/site-packages/archinstall/lib/disk/device_handler.py", line 287, in _validate_partitions
    raise exc
ValueError: Crypto luks cannot be set as a filesystem type
```

### Version
2.7.1


Discussion:
Thanks for the comprehensive steps! 
It seems there is some issues with the partition that is meant to be deleted. 
We'll have a look at it

Resolving patch:
diff --git a/archinstall/lib/disk/device_handler.py b/archinstall/lib/disk/device_handler.py
--- a/archinstall/lib/disk/device_handler.py
+++ b/archinstall/lib/disk/device_handler.py
@@ -296,15 +296,15 @@ def format(
 		the formatting functionality and in essence the support for the given filesystem.
 		"""
 
-		# don't touch existing partitions
-		filtered_part = [p for p in device_mod.partitions if not p.exists()]
+		# only verify partitions that are being created or modified
+		create_or_modify_parts = [p for p in device_mod.partitions if p.is_create_or_modify()]
 
-		self._validate_partitions(filtered_part)
+		self._validate_partitions(create_or_modify_parts)
 
 		# make sure all devices are unmounted
 		self._umount_all_existing(device_mod.device_path)
 
-		for part_mod in filtered_part:
+		for part_mod in create_or_modify_parts:
 			# partition will be encrypted
 			if enc_conf is not None and part_mod in enc_conf.partitions:
 				self._perform_enc_formatting(
diff --git a/archinstall/lib/disk/device_model.py b/archinstall/lib/disk/device_model.py
--- a/archinstall/lib/disk/device_model.py
+++ b/archinstall/lib/disk/device_model.py
@@ -793,6 +793,9 @@ def exists(self) -> bool:
 	def is_exists_or_modify(self) -> bool:
 		return self.status in [ModificationStatus.Exist, ModificationStatus.Modify]
 
+	def is_create_or_modify(self) -> bool:
+		return self.status in [ModificationStatus.Create, ModificationStatus.Modify]
+
 	@property
 	def mapper_name(self) -> Optional[str]:
 		if self.dev_path:
diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py
--- a/archinstall/lib/disk/filesystem.py
+++ b/archinstall/lib/disk/filesystem.py
@@ -55,8 +55,9 @@ def perform_filesystem_operations(self, show_countdown: bool = True):
 			device_handler.format(mod, enc_conf=self._enc_config)
 
 			for part_mod in mod.partitions:
-				if part_mod.fs_type == FilesystemType.Btrfs:
-					device_handler.create_btrfs_volumes(part_mod, enc_conf=self._enc_config)
+				if part_mod.is_create_or_modify():
+					if part_mod.fs_type == FilesystemType.Btrfs:
+						device_handler.create_btrfs_volumes(part_mod, enc_conf=self._enc_config)
 
 	def _do_countdown(self) -> bool:
 		SIG_TRIGGER = False


Test patch: