canonical / canonical/multipass

Launch command fails on a long instance name

Open
#4,889 3 comments 0 reactions 1 assignee Claimed by @AhmedMagdy9876 View on GitHub
Dominant language
C++
Stars
9.2k
Forks
828
Avg merge
3d 1h
Merged PRs (30d)
44

Description

**Describe the bug**
On both the GUI and CLI, the launch command fails if the provided instance name is very long. This is because of the OS limitation on folder names.

**To Reproduce**

## 1. CLI
1. `multipass launch --name abcdjvkcwwuqdxgkvihthjhndimukwzzxwxtrjueurnbngmeptfmjydifqiivbhhgpppqnkbnvnmfgnzrhkbdzwayuadujtdcdnqvadnfpbjuxunjzfuugbnbhfvbuuaabhbpjvfnagmcxdzigfnpvfdytrzukbudqazygwhhyezkuhaxrcjdmihqiuccgqvucaynncvcekkmmvanpbbpdibftmuittdvnhvyfhuyuqzjefyjcqyqwgingtjtfwfikvqtyynmvcnmenfpavngrwtzcgncyndijtqciihcuupudenhjrqcepzxahravijivjdpjajzrznqiuukgdyxuqpecixeqbvzwufmmnxygepzujatencvmpupbmgfiejcizfdcvdzbvyiawcpnuuffyqrjdntrmeztktwfhbvvxgiuixkfnfpzqgnargdpvxdtypzfmpbggwhjwyuqjzuvhnmtcaqqbgekxjumnknczgipgdzxxnbhxgr`
2. The CLI starts downloading the image and shows an error. The full log is
```
multipass launch --name abcdjvkcwwuqdxgkvihthjhndimukwzzxwxtrjueurnbngmeptfmjydifqiivbhhgpppqnkbnvnmfgnzrhkbdzwayuadujtdcdnqvadnfpbjuxunjzfuugbnbhfvbuuaabhbpjvfnagmcxdzigfnpvfdytrzukbudqazygwhhyezkuhaxrcjdmihqiuccgqvucaynncvcekkmmvanpbbpdibftmuittdvnhvyfhuyuqzjefyjcqyqwgingtjtfwfikvqtyynmvcnmenfpavngrwtzcgncyndijtqciihcuupudenhjrqcepzxahravijivjdpjajzrznqiuukgdyxuqpecixeqbvzwufmmnxygepzujatencvmpupbmgfiejcizfdcvdzbvyiawcpnuuffyqrjdntrmeztktwfhbvvxgiuixkfnfpzqgnargdpvxdtypzfmpbggwhjwyuqjzuvhnmtcaqqbgekxjumnknczgipgdzxxnbhxg

Creating abcdjvkcwwuqdxgkvihthjhndimukwzzxwxtrjueurnbngmeptfmjydifqiivbhhgpppqnkbnvnmfgnzrhkbdzwayuadujtdcdnqvadnfpbjuxunjzfuugbnbhfvbuuaabhbpjvfnagmcxdzigfnpvfdytrzukbudqazygwhhyezkuhaxrcjdmihqiuccgqvucaynncvcekkmmvanpbbpdibftmuittdvnhvyfhuyuqzjefyjcqyqwgingtjtfwfikvqtyynmvcnmenfpavngrwtzcgncyndijtqciihcuupudenhjrqcepzxahravijivjdpjajzrznqiuukgdyxuqpecixeqbvzwufmmnxygepzujatencvmpupbmgfiejcizfdcvdzbvyiawcpnuuffyqrjdntrmeztktwfhbvvxgiuixkfnfpzqgnargdpvxdt

Verifying image: |
Preparing image for abcdjvkcwwuqdxgkvihthjhndimukwzzxwxtrjueurnbngmeptfmjydifqiivbhhgpppqnkbnvnmfgnzrhkbdzwayuadujtdcdnqvadnfpbjuxunjzfuugbnbhfvbuuaabhbpjvfnagmcxdzigfnpvfdytrzukbudqazygwhhyezkuhaxrcjdmihqiuccgqvucaynncvcekkmmvanpbbpdibftmuittdvnhvyfhuyuqzjefyjcqyqwgingtjtfwfikvqtyynmvcnmenfpavngrwtzcgncyndijtqciihcuupudenhjrqcepzxahravijivjdpjajzrznqiuukgdyxuqpecixeqbvzwufmmnxygepzujatencvmpupbmgfiejcizfdcvdzbvyiawcpnuuffyqrjdntrmeztktwfhbvvxgiuixkfnfpzq

launch failed: unable to create directory '/var/root/Library/Application Support/multipassd/qemu/vault/instances/abcdjvkcwwuqdxgkvihthjhndimukwzzxwxtrjueurnbngmeptfmjydifqiivbhhgpppqnkbnvnmfgnzrhkbdzwayuadujtdcdnqvadnfpbjuxunjzfuugbnbhfvbuuaabhbpjvfnagmcxdzigfnpvfdytrzukbudqazygwhhyezkuhaxrcjdmihqiuccgqvucaynncvcekkmmvanpbbpdibftmuittdvnhvyfhuyuqzjefyjcqyqwgingtjtfwfikvqtyynmvcnmenfpavngrwtzcgncyndijtqciihcuupudenhjrqcepzxahravijivjdpjajzrznqiuukgdyxuqpecixeqbvzwufmmnxygepzujatencvmpupbmgfiejcizfdcvdzbvyiawcpnuuffyqrjdntrmeztktwfhbvvxgiuixkfnfpzqgnargdpvxdtypzfmpbggwhjwyuqjzuvhnmtcaqqbgekxjumnknczgipgdzxxnbhxg'
````

## 2. GUI
1. The GUI starts downloading the image and shows the "launching state". The GUI also shows a black ribbon across the screen with the long name which is not a good user experience.
Image
2. The GUI displays the error.

Image

The error message is:
`unable to create directory '/var/root/ Library/Application Support/multipassd/ qemu/vault/instances/jvkcwwuqdxgkviht
hjhndimukwzzxwxtrjueurnbngmeptfmjydi
faiivbhhgpppqnkbnvnmfgnzrhkbdzwayu
adujtdednqvadnfpbjuxunjzfuugbnbhfvbu
uaabhbpjvfnagmoxdzigfnpvfdytrzukbudq
azygwhhyezkuhaxrcjdmihqiuccgqvucayn
ncvcekkmmvanpbbpdibftmuittdvnhvyfhu
yuązjefyjcąyqwgingtjtfwfikvątyynmvcn...`

**Expected behavior**
1. In the CLI, there should be an instant error message if the name exceeds a certain string length.
An example would be

```
multipass launch --name
launch failed: instance name too long ( chars, max )

Instance names map to filesystem directories and must fit OS limits.
Allowed: 1– chars, [a-zA-Z][a-zA-Z0-9-]*

Try: multipass launch --name
```
We can also truncate the echoed instance name in the error log to make the logs/error message readable. If you look at provided terminal logs in the previous section, they are not great design.

### Something to debate:
We could still launch an instance by truncating the long instance name to the max allowed length and issue a warning in the terminal.
```
multipass launch --name abcdjvkcwwuqdxgkvi...nbhxgr
warning: name truncated to chars → 'abcdjvkcwwuqdxgkvihthjhndimukwzzxwxtrjueurnbngmeptfmjydifqiivbh'
original was 612 chars (OS filesystem limit)
use --strict-name or --force etc to fail instead

Launched: abcdjvkcwwuqdxgkvihthjhndimukwzzxwxtrjueurnbngmeptfmjydifqiivbh
```

The tradeoff here is that the process is convenient but there is a silent collision risk if two long names share prefix

3. In the GUI, a text input validator on the name form field should have a validation check for string length.

**Additional info**
- OS: MacOS Tahoe 26.5
- CPU architecture or model: Apple M1

We also need to find out what is the max string length that is allowed by the various OS.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.