Skip to content

v1.42.1

Choose a tag to compare

@hermanekt hermanekt released this 06 Nov 10:45
· 4 commits to main since this release
dd94fbc

Two things. In the server: a restart took 90 seconds whenever a client of the newer protocol was connected. And scripts/restore_trigger_macros.py, which finds what v1.40 and v1.41 did to trigger expressions, could answer "nothing lost" when something was, and in a few narrow cases could write back more than it should. Found by the reviews of v1.42 as released and on the first production update, in the hours after it went out. If you ran the script from v1.42 and it reported nothing, run this one again.

Fixed

  • systemctl restart zabbix-mcp-server took 90 seconds and ended in SIGKILL while a client of the 2026-07-28 protocol was connected (Claude Code is one). Such a client keeps one request open for as long as it is connected: subscriptions/listen, whose answer is a stream of notifications. The MCP library ends that stream when the client goes away, not when the server stops, and uvicorn does not exit while a response is open, so the stop ran into the 90 seconds systemd allows: State 'stop-sigterm' timed out. Killing. in the journal, and Failed with result 'timeout'. Whether it happens depends on the uvicorn that is installed (0.42 and 0.54 wait, 0.44 tells the stream itself and then cuts it), and an update of this server keeps the one that is there. The server now ends those streams itself the moment it is told to stop, as a response that is properly finished, and the client connects again when the server is back (Claude Code does, within seconds). A request that is being worked on has 30 seconds to finish; after that uvicorn cancels it, the client gets an error or a cut stream, and a write that Zabbix had already taken may still be applied. Before, that limit was systemd's 90 seconds and SIGKILL. On uvicorn 0.44 nothing changes for such a request: there uvicorn itself stops every open request at once, as it did before. In a container Docker's own stop timeout (10 seconds by default) comes first. Not new in v1.42: it came with the 2026-07-28 transport and the clients that speak it.

The rest is the script:

  • A macro that went in an update which changed something else as well was not listed. A model that is asked to change the expression itself edits the text it was given, and in v1.40 / v1.41 that text had the values where the macros were: avg(/h/k,10m)>{$MAX} came back as avg(/h/k,5m)>75. The script looks for updates in which nothing but macros changed, since only those can be undone by rule, and so it passed this one over and ended with "No trigger or trigger prototype is without a user macro it had" and exit status 0. Such an update is now listed as REVIEW with the expression the trigger has now, the one before that update and the macros that went, counted as left, and never written back: what else changed in it may be wanted. That holds for a macro that stood in two places and went from one of them, and for a macro that went while another was added elsewhere in the expression. A macro that somebody took out on purpose in such an edit is listed too; --user with the MCP server's Zabbix user keeps those out. A trigger that a template or a prototype gives to a host is left to that template or prototype, which is listed on its own.
  • A macro lost earlier was passed over once a later loss followed. Both macros of a>{$A} and b>{$B} lost, {$A} typed back by hand, {$A} lost again: the script restored {$A} and said nothing about {$B}, on that run and on every later one. Every update in which a macro went is now looked at, not only the newest run of them, against the expression as the restore leaves it; a macro the expression has not had back since is listed as REVIEW.
  • --user=NAME was not taken in, and the restore then ran over everybody's updates. Only --user NAME was read; --user=NAME, --days=N and a misspelt option were dropped without a word. Both forms are read now and anything the script does not know is refused (exit status 2). A --user Zabbix does not have is refused as well, instead of ending in "nothing lost", and for a user who updated no trigger in that time the script says so and names those who did. An error (Zabbix not reached, a call refused) ends with exit status 2 and one line, not with the 1 that means something is left. A password that begins with a dash now needs the options first and -- before the URL.
  • With --user, the restore could take back another user's update. Updates that only turned macros into values are followed back as one run, and the run did not end at an update by somebody else. a>{$A} and b>{$B}, made a>1 and b>{$B} by an administrator and then a>1 and b>2 by the MCP server's user, was restored with --user to a>{$A} and b>{$B} (the values are checked against the macros, so only where 1 is what {$A} has). The run now ends at another user's update: that trigger is restored to a>1 and b>{$B}, and one that another user changed afterwards is SKIPPED.
  • A value could pass the check without being what the macro stands for. Before anything is restored, the values that were written are compared with the macros. That comparison went by the macro's name, over the host, its templates and the global macros together: 80 typed where {$FS.MAX:"/var"} (95) stood was restored when {$FS.MAX} was 80, and the threshold moved to 95; the same for a host's own value next to its template's. The macro is now looked up in the order the Zabbix frontend uses when it expands an expression (read from its source, CMacrosResolverGeneral): the macro with the context asked for, or with a regular expression that matches it, on the host, on its templates level by level, then among the global macros, and only then the macro without a context; for a trigger on several hosts, the host with the lowest ID first. Only a regular expression plain enough to mean the same in Python as in Zabbix's PCRE is evaluated; with any other the trigger is left for review. A vault macro is treated like a secret: Zabbix expands both to a mask, so a value where one stood was typed by somebody. Where the macros went in two updates, every value of both is checked; only the last update's were when the two could not be read as one change.
  • A trigger whose macros somebody had typed back stayed listed as SKIPPED, on every run until the log forgot it: lost, edited, and the macro then written into the edited expression. It is no longer listed once every macro that went is there again as often as before. A trigger that was changed where the log does not see it (the log switched off for a while, a write to the database) is judged by the expression it has now, not by what the log says happened to it.
  • An expansion with two values next to each other was taken for an edit: x>{$A}-{$B} stored as x>-5-3 can be split in more than one way, and the first way tried did not fit. Each place now takes only a value of the shape that place allows, so it is read as what it is and restored.
  • More than 2000 trigger updates recorded in one second: the ones beyond the page were passed over. The second a page ends in is now read whole.
  • A value written as 1e3, .5 or 5. was not taken for a number, so an expansion to it was not recognised.
  • A trigger prototype made by a nested discovery rule (Zabbix 7.4 and later) was treated as one of its own and written to; it is left to the prototype it comes from, like a discovered trigger.
  • With --user, the date in a line was that of the trigger's first update by anybody; it is the first by that user. SKIPPED showed the earlier expression of whichever field came first, not of the one that was changed since.

Changed

  • The script's help, scripts/README.md and the README say what the script does and does not undo, and recommend --user with the Zabbix user of the MCP server's API token: when somebody typed on purpose the very number the macro has, the audit log cannot tell that from the trace of the bug.
  • Two things the script does not see are named there as well: one macro put in the place of another with nothing else changed, which is somebody's choice; and, since macros are counted over the whole expression and not place by place, a loss in one place where the same macro stands or is later written in another place, which can go unnoticed or be listed under another update than the one it went in.

Tests

  • 1127 tests (60 new). tests/test_stop_notification_streams.py (15): the layer that ends the streams, against an application that behaves as the library does (told once the server stops, the response finished, a request that is being worked on left alone and given the server's own callables, a client that leaves by itself, uvicorn telling first, a request body still arriving, nothing left running); and the real server with a stream held open the way Claude Code does, stopped with SIGTERM: quiet between two keep-alives, three streams being kept alive, nobody connected. tests/test_restore_trigger_macros.py (45): the larger edit seen, listed and never written, for one user's updates only, after an earlier loss was repaired and next to a plain expansion in the same field (the restore of the one must not hide the other); a macro gone from one of two places, and one gone while another was added; an earlier loss that was only partly repaired, named next to the restore of the later one and again on the next run; not listed for an inherited trigger, which follows its template; a trigger counted once whatever is said about it; one macro in the place of another left alone; with --user, the run ending at another user's update in both directions, and a name Zabbix does not have refused; the command line in both forms, with everything it does not know refused; the lookup of a macro in Zabbix's order, by level and by context, with quoted, unquoted and escaped contexts, regular expressions (matching, not matching, and the ones not evaluated here), two hosts, a secret and a vault macro; a trigger with a hundred macros read in no time; a trigger changed where the log does not see it; the script compiled with warnings as errors; the values of every step checked; macros typed back in an edit of somebody's own; two values next to each other; the date and the field a line is about; an error as exit status 2; the number forms; more updates in one second than a page holds; a discovered trigger prototype; and a trigger in the form Zabbix stores it ({functionid}), rebuilt before it is compared with the log, which the fake Zabbix of v1.42's tests never returned.
  • Live on 6.0.48, 7.0.30 and 8.0.0: the three variants of v1.42 (what v1.41 did, restored; edited afterwards, skipped; a number of somebody's own, left for review), the expanded text edited (listed for review and left as it is), and an edit that took one macro followed by the expansion of another (the second restored, the first still named on the next run); each trigger put back afterwards. The macros of those triggers are ones with a context that only the template's macro without one answers, and one with its own context inside a quoted string. The command line on 7.0.30: --user=NAME, an option it does not know, a user Zabbix does not have, Zabbix not reached and a wrong password.
  • The restart: with two idle Claude Code clients connected, v1.42 was still running 25 seconds after SIGTERM and this release stops in 0.2 seconds, with nothing but the usual lines in the log. The real-server tests ran twelve times under CPU load with each of three sets of libraries: the ones of two production installs (uvicorn 0.42.0 with mcp 2.2.0, uvicorn 0.44.0 with mcp 2.0.0) and the newest (uvicorn 0.54.0). Against v1.42 the same tests fail.