Files
openwaf/scripts
Pavlo Ratushnyi 6e6461a760 A 404 explained one missing row and said nothing about another, and the page answered the silent one with "the admin API is off"
Measured on the shipped image (openwaf:ci 08bebf43, the tree with the
storage-failure fix):

  DELETE /admin-api/countries/ZZ   -> 404 {"error":"no country rule for \"ZZ\""}
  DELETE /admin-api/allow/999999   -> 404, Content-Length: 0

Same status, two qualities of answer. The silent half is what the console then
had to invent an explanation for: apiRaw read EVERY 404 as
"admin api disabled — set OpenWaf__Admin__Token" and threw, so removing a row
that another tab had already removed told the operator to go configure a token
that is already configured. And because the throw landed in a catch that says
nothing, the status line ended up reading "refreshed" in the success colour —
measured in the console gate before the fix:

  FAIL a missing row is reported as a missing row… — ok: refreshed 4:50:18 AM

After the fix, on the image built from this tree (4823e9ae):

  DELETE /admin-api/allow/999999   -> 404 {"error":"no allow entry with id 999999"}

The page now shows that sentence instead of guessing:

  ok  a missing row is reported as a missing row, not as the admin API being switched off
      — warn: no allow entry with id 999999

Whether the admin surface is switched off at all is no longer inferred from a
status code: the core read (/admin-api/state) is checked for a non-200 and the
edge's own body is shown — "admin api disabled: set OpenWaf__Admin__Token",
which the API already says and which a new test pins.

While in this handler, the most destructive button on the page was found doing
worse than lying: "clear the automatic bans" fired the DELETE and read nothing
back, so cleared 7, cleared 0 and a refused write looked identical after the
reload. It now reports the count the edge gave ("engine bans cleared: 0"), and
the note for the action just taken survives the refresh that action itself
triggered — load() used to overwrite it with "refreshed" inside a second, which
is shorter than the time it takes to read.

Gates on this tree (macOS): build 0 warnings / 0 errors, unit 128/128,
integration 109/109 (3 new in NotFoundExplanationTests), smoke 19/0,
compose 43/0, image 261 MB, console 47/47 (2 new assertions).
Dents: allow 404 silent again -> 2 tests fail; apiRaw reading every 404 as
"disabled" -> 2 console assertions fail; clearEngine reading nothing back -> 1;
the action note not held across its own refresh -> 1.
2026-10-02 05:21:44 +02:00
..