fix: accept either bootstrap URL shape, in dotup and in the harness

Three files each appended /bootstrap.env to a value whose shape nobody had
pinned down, and they did not agree:

  - the rotation scripts print the FULL file URL and say to store THAT in
    Bitwarden, so that is what gets pasted
  - dotup asked for the directory and appended /bootstrap.env itself
  - .tests/e2e.sh independently duplicated dotup's assumption

Pasting the saved value made the request .../bootstrap.env/bootstrap.env. The
404 tripped curl --fail and surfaced as "endpoint refused the credentials. The
machine stays public-only" -- blaming the password for a URL shape, which is
about the most expensive wrong error message this path could produce.

dotup and the wrapper now both strip a trailing slash and a trailing
/bootstrap.env before building the request, so either form works and the
existing Bitwarden entry needs no editing.

Four assertions cover all four shapes -- directory and file URL, each with and
without a trailing slash. They eval the normalisation lifted straight out of
dotup rather than a copy, and that binding was mutation-tested: deleting the
line from dotup makes them fail with exactly the production symptom,
https://h/r/bootstrap.env/bootstrap.env. 101 -> 105.

The second instance, in e2e.sh, was found only by running the harness with the
file URL instead of the directory. Every earlier run passed because it was fed
the shape that happened to be in a variable, not the shape a person has in a
password manager. Both shapes now run end to end and pass.

The normalisation exists in two places because the harness cannot source
dotup's internals. That is the same duplication that caused this, and only
dotup's copy is covered by the suite.
This commit is contained in:
bcherb2
2026-08-17 22:52:11 -04:00
parent 2a93bfd5b1
commit 2afdfd093b
3 changed files with 31 additions and 0 deletions
+7
View File
@@ -784,6 +784,13 @@ cmd_private() {
P_URL=''; P_USER=''; P_PW=''
printf ' Bootstrap URL: ' >&2; IFS= read -r P_URL || :
[ -n "$P_URL" ] || { say " public-only machine. Nothing was asked for."; return 0; }
# Accept the directory OR the full file URL, because both are in circulation:
# the rotation scripts print the file form and say to store THAT in Bitwarden,
# so pasting what you saved is the likely case. Without this, the request
# becomes .../bootstrap.env/bootstrap.env, the 404 trips curl --fail, and the
# error below blames the credentials for what is actually a URL shape.
P_URL=${P_URL%/}
P_URL=${P_URL%/bootstrap.env}
printf ' Username: ' >&2; IFS= read -r P_USER || :
printf ' Password: ' >&2
stty -echo 2>/dev/null || :; IFS= read -r P_PW || :; stty echo 2>/dev/null || :; printf '\n' >&2