{
  "id": 2873419,
  "title": "Don't validate the output. Validate that you were allowed to generate it.",
  "url": "https://urgent.news/2026/08/23/dont-validate-the-output-validate-that-you-were-allowed-to-generate-it",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-23T21:24:03.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/takahiro_hashito_a1f3f0dc/dont-validate-the-output-validate-that-you-were-allowed-to-generate-it-2ekh"
  },
  "original_language": "en",
  "account": "My site aggregates foreign viewer comments about individual anime episodes, translating and publishing them daily. A critical failure mode is generating pages for episodes that have not aired yet. If such a page exists before the broadcast, there are no comments to add. However, an empty page can be filled with plausible content by an automated system, creating false information. This post explains the check that prevents this issue and when it actually triggered.\n\nThe straightforward approach would involve date arithmetic, calculating weeks elapsed since the air date of episode 1. However, this method does not guarantee that an episode actually aired; skipped weeks or recap episodes could alter the count. Thus, I split the pipeline into two stages: candidate generation using weekly arithmetic and existence check by verifying if an observation from outside my system exists for the episode. The existence check relies on per-episode discussion threads on MyAnimeList (MAL), where a thread is created for each episode after it airs, and the timestamp of the first post serves as external evidence of the broadcast.\n\nThe check function subtracts the claimed air date from the observed date from MAL, returning the gap in days and a status indicating whether the episode was aired within a five-day tolerance. For example, an episode aired on 2026-07-28 with a MAL timestamp of 2026-07-28T14:25:51.000Z would result in a gap of 1 day and a status of \"ok\". Conversely, an episode aired on 2026-08-23 with a MAL timestamp of 2026-07-28T14:25:51.000Z would have a gap of -25 days and a status of \"mismatch\".\n\nRunning the check on real values, the function returned a gap of 1 day and \"ok\" status for an episode aired on 2026-07-28. Conversely, an episode aired on 2026-08-23 with a MAL timestamp of 2026-07-28T14:25:51.000Z resulted in a gap of -25 days and a status of \"mismatch\". The arithmetic is simple, but the crucial aspect is the asymmetry between the left and right operands in the comparison. Using the same side of the line for both operands would not validate anything. Additionally, a five-day tolerance accounts for time zones and streaming delays, allowing for a small window of error.\n\nOnce the per-episode results are aggregated, the function checks if all episodes passed the air date check. If any episode failed, the function returns early, preventing the fetching of comments for that episode. This ensures that only valid episodes are processed, avoiding the creation of false information. The same check also prevents under-collection, as it verifies that the observed episode number matches the claimed one. If the observed number is lower, it indicates that the episode did not air yet.\n\nFor instance, on the day of the check, episodes 4 through 7 were missing, so four page stubs were created and comments were fetched. However, all four stubs claimed the same air date - the current date. This was a bug in the stub generator, which defaulted the air date to the current date instead of leaving it unset. The bug was invisible by inspection, as the date appeared valid, but it became clear when compared to an external observation - it was minus twenty-five days. After fixing the bug and re-running the check, all episodes passed, and no comments were fetched, resulting in a successful run with 32 comments from the same threads.\n\nFinally, the same check also prevents under-collection. If an episode has not aired yet, the weekly arithmetic might suggest it as a candidate, but if MAL has no discussion thread for that episode, the observed episode number will be lower. In such cases, the observed number wins, ensuring that only valid episodes are processed and preventing the generation of false information. By implementing this gate before generation rather than after, we ensure that automated pipelines do not emit convincing falsehoods due to an unverified precondition.",
  "summary": "Introduction I run a site that collects overseas viewer comments about individual anime episodes, translates them, and publishes them. It updates automatically every day. There is one failure mode that matters more than all the others: creating a page for an episode that has not aired yet. If the page exists before the broadcast, there are no comments to put on it. But the heading \"Episode 8 —…",
  "key_points": [
    "Check function compares claimed air date with observed date from MyAnimeList (MAL)",
    "Five-day tolerance accounts for time zones and streaming delays",
    "Early exit if any episode fails air date check to prevent false information generation"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}