Fixing one silent failure uncovered seven more

本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。

Last week I wrote about my YouTube automation that kept “running” for almost six months: 1,376 commits, every run green, zero uploads. An OAuth app left in Testing status meant every refresh token died after 7 days, and nothing turned red. This is the follow-up.

上周我写到了我的 YouTube 自动化程序,它在近六个月里一直处于“运行”状态:提交了 1,376 次,每次运行都显示成功,但上传量为零。由于一个 OAuth 应用留在了测试状态,导致每个刷新令牌在 7 天后就会失效,而系统却没有任何报错。这是后续报道。

The first channel is posting again. I also built a small watchdog, and pointed it at my second channel, The Obscura Files. That one had been dead for 7 months (last video: April 16). I expected one bug. I found seven, stacked on top of each other. Each fix let the pipeline run a little further, straight into the next silent failure. Seven layers, one channel. Every layer below was hidden by the one above it. None of them produced an alert on its own.

第一个频道恢复了更新。我还构建了一个小型监控程序,并将其指向我的第二个频道“The Obscura Files”。该频道已经停更了 7 个月(最后一段视频发布于 4 月 16 日)。我本以为只有一个错误,结果却发现了七个堆叠在一起的问题。每一次修复都让流水线向前推进了一点,随即又陷入下一个静默故障。七层故障,一个频道。每一层都被上一层掩盖,没有任何一个故障能单独触发警报。

What broke Why nobody saw it

1 config/config.yaml was never committed. Every run failed at startup. It also broke the other channel’s thumbnails, quietly. 2 Pillow was missing from requirements.txt. It only existed on branches that were never merged. My local venv had Pillow, so local checks passed. The first channel’s thumbnail code caught the exception and wrote a warning to a log file that is only kept when a run fails. 3 The runner ran out of memory. ffmpeg was crossfading ~110 clips in a single call. The runner died so hard that GitHub kept no log at all. Just “lost communication with the server”. 4 My fix (crossfade in chunks of 10) broke above 100 clips: the second level wrote to the same file it was reading. The original commit literally said UNVERIFIED. It only failed on the real clip count. 5 The memory cap wrapper (sudo systemd-run) dropped 66 environment variables, including my “skip upload” test flag. The test run was one step away from posting a real video. It was saved only by layer 6. 6 The OAuth token had 2 scopes. The code asked for 3 (youtube.force-ssl, for one comment after each upload). Google answered invalid_scope. This had been true since spring. Earlier layers failed before the code ever got here. 7 The first real upload in 7 months went up as private. The config had said private since April. Someone (me, months ago) used to publish by hand in YouTube Studio. When I stopped, the channel went dark while every run stayed green.

故障原因及为何无人察觉

  1. config/config.yaml 从未被提交。每次运行都在启动时失败,同时也静默破坏了另一个频道的缩略图。
  2. requirements.txt 中缺少 Pillow 库。它只存在于从未合并的分支中。我的本地虚拟环境有 Pillow,所以本地检查通过了。第一个频道的缩略图代码捕获了异常,并将警告写入了一个仅在运行失败时才保留的日志文件中。
  3. 运行器内存耗尽。ffmpeg 在单次调用中对约 110 个片段进行交叉淡入淡出处理。运行器崩溃得太彻底,以至于 GitHub 根本没有留下日志,只显示“与服务器失去连接”。
  4. 我的修复方案(分 10 个片段进行交叉淡入淡出)在超过 100 个片段时失效:第二层在写入时读取了同一个文件。原始提交记录明确写着“未验证”。它只在实际片段数量达到阈值时才会失败。
  5. 内存限制包装器 (sudo systemd-run) 丢失了 66 个环境变量,包括我的“跳过上传”测试标志。测试运行距离发布真实视频仅一步之遥,幸亏被第 6 层拦截才未酿成大错。
  6. OAuth 令牌只有 2 个作用域,但代码请求了 3 个(youtube.force-ssl,用于每次上传后的评论)。Google 返回了 invalid_scope。这种情况从春天起就一直存在,但之前的故障层在代码运行到这里之前就已中断。
  7. 7 个月来的第一次真实上传被设为私有。配置文件自 4 月起就一直设为私有。以前(几个月前)有人(我)习惯在 YouTube 工作室手动发布。当我停止手动操作后,频道就陷入了沉寂,而系统运行状态却一直显示正常。

The fixes were small: one config file, one dependency, chunked crossfades, unique file names per level, passing the full environment through, a fresh login with all three scopes, and scheduled publishing via publishAt. After layer 5, I changed how test runs work. A test run no longer receives the YouTube credentials at all. If the skip flag fails again, the uploader has nothing to log in with.

修复工作很小:一个配置文件、一个依赖项、分块交叉淡入淡出、每层使用唯一文件名、传递完整环境变量、使用全部三个作用域重新登录,以及通过 publishAt 进行定时发布。在第 5 层之后,我更改了测试运行的方式。测试运行现在完全不再接收 YouTube 凭据。如果跳过标志再次失效,上传程序将因没有登录凭据而无法操作。

What the watchdog caught, and what it missed The watchdog is quiet-pipelines. It does not ask “did the job succeed?”. It asks “did a new public video actually appear?”, from outside the pipeline, once a day. On its first real run it opened two GitHub Issues: The Obscura Files: no new output. It stayed open through all seven layers. When the private upload finally went up, it still stayed open, because it only counts public videos. That was the right call.

监控程序捕获了什么,又错过了什么 监控程序名为 quiet-pipelines。它不问“任务是否成功?”,而是每天从流水线外部询问“是否有新的公开视频出现?”。在第一次实际运行中,它开启了两个 GitHub Issue:The Obscura Files 没有新输出。在经历全部七层故障期间,该 Issue 一直保持开启。当私有视频最终上传时,它依然保持开启,因为它只统计公开视频。这是正确的判断。

An expiry ledger item. The Claude model my script generator used retires on Nov 30. After I migrated, the next run closed that Issue by itself. The migration had its own trap. Swapping only the model name would have failed silently: the new model thinks before answering, the old max_tokens=500 was used up by thinking, and the code fell back to a template script. Green run, worse videos.

一个过期记录项。我的脚本生成器使用的 Claude 模型将于 11 月 30 日退役。在我迁移后,下一次运行自动关闭了该 Issue。迁移过程本身也有陷阱:仅替换模型名称会导致静默失败——新模型在回答前会进行思考,旧的 max_tokens=500 限制被思考过程耗尽,代码回退到了模板脚本。运行显示成功,但视频质量变差了。

What it missed: the first channel’s thumbnails. Videos were going up, so the output check was happy, but the custom thumbnail step was failing behind a caught exception. The watchdog checks that output exists, not whether it is complete. A reader on my last post described a better check for this: compare the volume of output with the previous run, and fail when it drops by half. A job that exits clean with nothing in it passes every heartbeat.

它错过了什么:第一个频道的缩略图。视频在上传,所以输出检查显示正常,但自定义缩略图步骤在被捕获的异常后失败了。监控程序只检查输出是否存在,而不检查其是否完整。我上一篇文章的一位读者描述了一种更好的检查方法:将输出量与上一次运行进行比较,如果下降了一半则判定失败。一个干净退出但没有任何产出的任务,在每次心跳检测中都会通过。

How good is the AI diagnosis? Honest numbers When a check fails, the watchdog can send an excerpt of the failed log (secrets masked twice) to Claude and ask for a category: expired auth, upstream change, quota, code bug, or unknown. Low-confidence answers are forced to “unknown” in code.

AI 诊断效果如何?真实数据 当检查失败时,监控程序可以将失败日志的摘录(密钥已双重掩码)发送给 Claude,并要求其分类:凭据过期、上游变更、配额限制、代码错误或未知。置信度低的回答在代码中会被强制归为“未知”。

[Table omitted for brevity] The first row is in-sample: I looked at those cases while writing the prompt. The second row is the fairer measure, and it is biased toward easy cases. I could only score failures whose fixing commit made the right answer obvious, so it has no expired-credential or quota cases at all. The three “unknown” answers all had the same cause: the deciding evidence was not in the log excerpt. For layer 3 above, there was no log at all. No model can diagnose that, which is why the outcome check matters more than the diagnosis.

第一行是样本内数据:我在编写提示词时查看了这些案例。第二行是更公平的衡量标准,但它偏向于简单案例。我只能评估那些修复提交能明确指向正确答案的故障,因此它完全不包含凭据过期或配额案例。三个“未知”答案的原因相同:决定性证据不在日志摘录中。对于上面的第 3 层故障,根本没有日志。没有任何模型能诊断出这种情况,这就是为什么结果检查比诊断更重要的原因。

What I’d tell myself six months ago A green run is a claim, not a result. The job is done when the video exists and is public, not when the process exits 0. Assume there is one more layer. Every fix moved the failure further down the pipeline. I stopped celebrating fixes and started waiting for the first real output. Swallowed exceptions are debt with no statement. try/except: log.warning(…) into a file that is deleted on success is the same as no log. Make test runs unable to do harm, not just told not to. A flag can get lost (mine did). Missing credentials cannot. Check what humans used to do by hand. The last layer was not a bug. It was a manual step that quietly stopped happening.

如果能回到六个月前,我会告诉自己: 运行成功只是一种声明,而非结果。任务完成的标志是视频真实存在且公开,而不是进程以 0 状态码退出。假设永远还有下一层故障。每一次修复都将故障推向了流水线的更深处。我不再为修复而庆祝,而是等待第一次真实输出。被吞掉的异常是没有任何对账单的债务。try/except: log.warning(…) 写入一个在成功后会被删除的文件,等同于没有日志。让测试运行在物理上无法造成伤害,而不仅仅是告诉它不要这样做。标志位可能会丢失(我的就是),但缺失凭据则无法丢失。检查人类过去手动执行的操作。最后一层故障不是 Bug,而是一个悄然停止的手动步骤。

Where it stands, and a question for you The Obscura Files uploaded again last night, its first upload in 7 months, and I published it by hand. Tonight’s run is the first one with scheduled publishing (15:00 UTC the next day), so nobody has to touch YouTube Studio. I’ll add a line here once it has actually gone public, because by now I don’t trust a green run until I see the output. quiet-pipelines is open source (MIT), v0.1.0: github.com/hisatsuneharukiq5-spec/q

现状及给你的一个问题 “The Obscura Files”昨晚再次上传了视频,这是 7 个月来的第一次,我手动发布了它。今晚的运行将是第一次使用定时发布(次日 15:00 UTC),这样就无需再触碰 YouTube 工作室。一旦视频真正公开,我会在这里补充一行说明,因为现在除非看到输出,否则我不再相信运行成功。quiet-pipelines 已开源 (MIT),版本 v0.1.0:github.com/hisatsuneharukiq5-spec/q