Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2761,7 +2761,7 @@ _account_already_prefixed() {
local current_name="$1"
local lower_name
lower_name=$(printf '%s' "$current_name" | tr '[:upper:]' '[:lower:]')
if [[ "$lower_name" == loki-* ]]; then
if [[ "$lower_name" == loki* ]]; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict prefix detection to names with a real separator

The new loki* check marks any AccountName starting with loki as already prefixed, but this path still assumes an exact Loki- prefix when it computes stripped_original via ${current_name:5}. For inputs like loki1-MyAccount or LokiDev-SomeAccount, the installer now writes malformed /loki/original-account-name values (e.g. -MyAccount, ev-SomeAccount), which corrupts the account-rename metadata this function persists on first install.

Useful? React with 👍 / 👎.

local display_name
display_name=$(printf '%s' "$current_name" | tr -d '\000-\037')
ok "Account already named for Loki: $(printf '%s' "$display_name")"
Expand Down
20 changes: 20 additions & 0 deletions tests/test-account-rename.sh
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,26 @@ test_already_prefixed_case_insensitive() {
assert_contains "detects case-insensitive prefix" "already named for Loki" "$_OUTPUT"
}; test_already_prefixed_case_insensitive

test_already_prefixed_loki_variant() {
source "$TMPDIR/functions.sh"
DISABLE_ACCOUNT_RENAME=false
_AWS_ACCOUNT_INFO_EXIT=0
_AWS_ACCOUNT_INFO_RESULT='{"AccountName":"loki1-MyAccount"}'
_OUTPUT="" _TELEM_EVENTS=()
maybe_rename_account
assert_contains "detects loki1- as already prefixed" "already named for Loki" "$_OUTPUT"
}; test_already_prefixed_loki_variant

test_already_prefixed_lokidev() {
source "$TMPDIR/functions.sh"
DISABLE_ACCOUNT_RENAME=false
_AWS_ACCOUNT_INFO_EXIT=0
_AWS_ACCOUNT_INFO_RESULT='{"AccountName":"LokiDev-SomeAccount"}'
_OUTPUT="" _TELEM_EVENTS=()
maybe_rename_account
assert_contains "detects LokiDev- as already prefixed" "already named for Loki" "$_OUTPUT"
}; test_already_prefixed_lokidev

test_headless_no_opt_in() {
source "$TMPDIR/functions.sh"
DISABLE_ACCOUNT_RENAME=false
Expand Down
Loading