An internal portal has a status page that builds itself. A scheduled job runs a report script, takes its JSON output, and renders it into HTML. On November 10 the page was showing October 28. It still loaded, it still looked complete, and it had not changed in thirteen days. It surfaced as a follow-up to a routine system check, not because anyone went looking for it.
Every run failed the same way
The job had not stopped. It kept starting on schedule, and every run failed at the same line of the build script. That line handed the report’s JSON to the renderer through an environment variable. When a process is started, its arguments and environment are copied into it together, and the total has a ceiling: ARG_MAX, which on this Mac is 1,048,576 bytes. The report counts what the system has observed, so it grows a little with every run. At some point it crossed the line, and from then on the shell could not start the renderer at all.
The logs I had show the failure on every run since at least November 6. The page’s last good build was October 28. Whether the failures began on the 28th or a few days later is not something the records settle. What is clear is the shape: the failure was total, and from the outside nothing looked broken. The previous HTML stayed on disk, the web server kept returning 200, and the error went to a log file that nobody was reading.
Pass a path, not the payload
The fix was small. The script now writes the JSON to a temporary file made with mktemp, passes only the file’s path to the renderer, and removes the file with a trap when it exits, whether or not the build succeeds. A path is a few dozen bytes no matter how large the report gets. Ten lines of the script changed.
I then triggered the scheduled job once by hand. It exited with status 0 and rebuilt the page from 16,374 observed items and 4,592 matches, about 1.2MB of HTML. The page answered with the new content, the error log gained no new lines, and no temporary file was left behind. Only one run was checked that day; the next scheduled runs are not in the log I wrote this from.
Two things to keep
The first is about the channel. Arguments and environment variables are for settings, which stay small. Data that grows with use belongs in a file, or on standard input. Passing it inline works until the day it doesn’t, and that day arrives without warning because nothing about the code changes.
The second is about the page. A generated page that fails to regenerate does not go blank. It keeps serving its last good copy, which looks exactly like a healthy page. The only signal is its age, so a generated page should say plainly when it was last built, and that time should be easy to compare against today. This fix did not add that; it is the part still worth doing.