Monday, October 20, 2025
It worked, but it failed
In posting the previous post I encounted an interesting bug!
It wasn't in mod_blog
per se,
but in the hook running after an entry has been added,
and therein is the bug—the entry was successfully added,
but the hook failed.
The hook program failed due to a compilation error that was only triggered when it ran.
I took the email notification code from mod_blog
and turned it into a program.
I also linked to the bloging core of mod_blog
to avoid having to duplicate the code to read the configuration
(the email notification block is now ignored by mod_blog
itself),
and because the configuration format is Lua,
a compiler option is needed to support Lua modules written in C—basically, -rdynamic
to allow C-based Lua modules to call Lua functions
(which I allow, and need, to support my particular configuration).
This is the root cause of the issue.
But in the meantime,
because the hook failed to run,
the script I use that uses the HTTP PUT
method received a status of “500 Internal Server Error,”
the entry was stored,
but none of the statically generated files
(index.html
and the various feed files)
were generated,
nor email sent.
Once I figured out what happened, it was easily remedied, but that still leaves the question of what should happen? I intended the add entry post-hook to handle situations like notifications, so in this case, if the hook fails, normal processing should proceed, but how to send back that the entry post-hook failed? Looking over the HTTP status codes, perhaps I could return a “202 Accepted” when the entry post-hook fails, with some information about the failure. That could work.