Anmeldung fehlgeschlagen: sagen, woran es liegt

Die Meldung nannte bisher nur die aufgerufene Adresse. Antwort,
HTTP-Code und curls eigene Fehlermeldung wurden weggeworfen - also
genau das, woran man es erkennt. Uebrig blieb Raten.

Jetzt werden alle drei eingesammelt und ausgewertet:

  HTTP 400/401  Der Proxy Manager hat geantwortet und abgelehnt. Damit
                ist auch gesagt, dass Port, Netz und Proxy stimmen. Die
                Meldung der Schnittstelle steht dabei ("Invalid email or
                password"), dazu der Hinweis auf npm-reset, falls das
                Konto nie angelegt wurde.
  HTTP 000      Gar keine Antwort. Der Reihe nach wird geprueft und
                benannt: NPM_ENABLED=off, Container laeuft nicht, auf
                dem Port lauscht nichts, oder er antwortet nur nicht.
  HTTP 5xx      Es hat etwas geantwortet, aber nicht wie erwartet.

Dazu: ist die Antwort HTML statt JSON, wird das ausdruecklich gesagt und
die erste Zeile gezeigt. Damit ist auf einen Blick erkennbar, dass ein
HTTP-Proxy geantwortet hat und nicht der Proxy Manager - im Test
"<html><head><title>502 Proxy Error</title>...".

Beim Pruefen der Faelle ist ein Fehler aufgefallen: container_running
benutzt RUNTIME ohne Absicherung. War die Runtime nicht erkannt, brach
die Fehlerdiagnose unter "set -u" mit "RUNTIME ist nicht gesetzt" ab -
ausgerechnet die Ausgabe, die helfen soll. Ohne erkannte Runtime lautet
die Antwort jetzt schlicht "nein".

Nebenbei korrigiert: NPM antwortet bei falschen Zugangsdaten mit 400,
nicht mit 401 - der erste Entwurf fing den haeufigsten Fall nicht.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-20 23:56:49 +02:00
co-authored by Claude Opus 5
parent eb29db0130
commit 62ccafbbd1
4 changed files with 204 additions and 22 deletions
+36
View File
@@ -1196,6 +1196,42 @@ the account from `NPM_ADMIN_EMAIL`/`NPM_ADMIN_PASSWORD` on the next `up`.
remain. The command shows exactly that beforehand and asks for confirmation.
The proxy hosts can be recreated with `proxy add` in a single call.
### 10.1.1 When the login fails
The message now names the cause itself – it shows the HTTP code, the API's
reply and, if nothing answered at all, what curl reported:
```
[FEHLER] Anmeldung am Proxy Manager fehlgeschlagen.
Aufgerufen : http://127.0.0.1:81/api/tokens
Konto : admin@example.com
HTTP-Code : 400
Antwort : Invalid email or password
Woran es liegen kann
Der Proxy Manager hat geantwortet und die Anmeldung abgelehnt.
Der Weg dorthin stimmt also - Port, Netz und Proxy sind in Ordnung.
```
That is half the battle: **if it answered, the network is not the problem.**
The other direction looks like this:
| HTTP code | meaning | next step |
|---|---|---|
| `400`/`401` | the Proxy Manager refuses | account/password in `.env`, or the account does not exist → `npm-reset` |
| `000` | no answer at all | container down? port free? – the command checks both and says which applies |
| `5xx` + HTML | something else answered | usually the HTTP proxy; the first line of the HTML reply is shown |
If HTML arrives instead of JSON, it says so explicitly – including the first
line, which reveals who answered:
```
Die Antwort ist HTML, kein JSON - sie stammt also nicht von der
Schnittstelle des Proxy Managers, sondern von etwas davor
(HTTP-Proxy, anderer Dienst auf dem Port). Erste Zeile:
<html><head><title>502 Proxy Error</title></head>...
```
### 10.2 Creating a proxy host – without a browser
The web interface is painful in a terminal browser, and forms with file uploads