You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(cli): register --server <unreachable> now fails with network_error (#72)
cmd_register ran its own curl with `… || true`, throwing away curl's exit
code. When the connection fails, `-w "%{http_code}"` prints "000"; both the
fallback (4xx) and error (>= 400) checks are false for "000", so an
unreachable --server fell through to the success path and exited 0 — the CLI
silently claimed a registration that never happened.
Capture curl's exit code (no `|| true`) and treat a non-zero exit OR an HTTP
"000" as a network_error, on both the JSON-wrapped POST and the raw-YAML
fallback. Mirrors api_call's existing handling.
The regression test (U2a #10) is hardened: it isolates OPENSOP_HOME so
--server is the only URL source (a developer's ~/.opensop would otherwise mask
the failure and the test could pass for the wrong reason) and asserts the
error code is network_error. Verified: pre-fix the test fails with the exact
reported symptom ("got exit 0"); post-fix the suite is 289 PASS.
Co-authored-by: Carlos <carlos>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: cli/CHANGELOG.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,18 @@ This project follows [Semantic Versioning](https://semver.org/) and the
23
23
always returns 0. Added a source-level guard in `test/test.sh` forbidding standalone
24
24
`(( var++ ))` / `(( var-- ))` increments so the footgun cannot reappear.
25
25
26
+
-**`register --server <unreachable>` exited 0 instead of failing.**
27
+
`cmd_register` ran its own `curl` with `… || true`, discarding curl's exit
28
+
code, and `-w "%{http_code}"` prints `000` when no connection is made. Both
29
+
the fallback check (`4xx`) and the error check (`>= 400`) are false for `000`,
30
+
so an unreachable server fell through to the success path and exited 0 — the
31
+
CLI silently reported a registration that never happened. Now curl's exit code
32
+
is captured (no `|| true`) and a non-zero exit or an HTTP `000` code is treated
33
+
as a `network_error` (mirroring `api_call`), applied to both the JSON-wrapped
34
+
POST and the raw-YAML fallback. The regression test isolates `OPENSOP_HOME` so
35
+
`--server` is the only URL source and asserts the `network_error` code, rather
36
+
than passing for the wrong reason when a developer `~/.opensop` is present.
37
+
26
38
## [0.8.0] — 2026-06-11
27
39
28
40
> **BREAKING:** The default backend is now **LOCAL**. Commands that previously hit a remote server by default now run locally (no server, no curl). Scripts relying on the old default-remote behaviour must add `--remote` (uses the configured `OPENSOP_URL`) or `--server <url>`. The `--local` flag is now a deprecated no-op and can be omitted — it is still accepted for script compatibility but prints a deprecation note to stderr.
|| { echo"FAIL: U2a register --server <unreachable> should emit network_error (curl 000 must not be treated as success), got: $u2a_reg_server_out";exit 1; }
3490
+
echo"PASS: U2a register --server <url> — unreachable server yields network_error (curl 000 not treated as success)"
3485
3491
3486
3492
# --- (11) 'run' with NO flag, explicitly NO --local — the file path form ---
3487
3493
# Exercise that the default-local path works when --local is ABSENT entirely.
0 commit comments