Find the boundary first#
Trace the value back to where it entered the system:
- Who sets it: an anonymous request, a signed-in user, an administrator, or your own code?
- What checked it on the way in: a request schema, a parser's types, a framework filter, or nothing?
- Where does it go next: storage, a shell or query, another user's browser, or arithmetic in a hot loop?
The OWASP Input Validation Cheat Sheet recommends allowlists and validating parsed values "before business processing or storage". That point is the boundary, not every function the value passes through. A second check deeper in the code helps only when some path skips the first.
A boundary that three comments argued over#
In October 2026, a GPUStack pull request added validation to icon URLs in the cache-provider catalog, a YAML document that administrators manage and that GET /v2/cache-providers returns to the UI. The merged code explains the boundary in its own comment: "A logo is an opaque URL a browser resolves", so a declaration that would store javascript: or an SVG data: URI "is refused here rather than served to every reader of the catalog." Pull request The shared validate_icon accepts absolute URLs, /-rooted paths and raster data:image/ URIs and refuses the rest. The tests cover javascript:alert(1), a tab inside the scheme, SVG and HTML data: URIs and a protocol-relative URL. MDN describes how a javascript: URL runs script on navigation.
The value crosses a real boundary, from an administrator's document into every viewer's browser, so three bot comments argued over where and how widely to check.
Copilot flagged a field the first commit missed: "Validate icons in nested L2 backends". Copilot comment The author agreed, "correct, and I'm folding it in," because the backends are "returned by the same GET /v2/cache-providers" and "both fields are the same kind of value reaching the same renderer." Author's reply Commit e497345 extended the check to l2_backends, and the merged tests cover a backend icon. Same boundary, missing coverage: a change.
gemini-code-assist asked to move the check out of normalize_cache_provider_yaml and "integrate it directly into load_cache_providers_document", where under strict=False it would be "logging a warning and skipping" "the malformed provider". Review comment The author declined: "I deliberately put it in normalize_cache_provider_yaml, because that is where both siblings do it," and "the established behaviour for a bad icon is refuse the document, not drop the declaration and log." The dismissal rests on the project's existing contract for that kind of value.
Copilot's third point, "Sanitize already-persisted icon payloads", concerned rows stored before the fix. The author called it "correct" but wrote "I don't think I should fix that unilaterally," since it "needs either a data migration or a read-path guard," and offered the maintainer two options: leave existing rows, or a one-time remediation "in a follow-up PR where the migration is the whole subject." The pull request merged on 12 October 2026 with a one-word approval and no recorded choice. Gemini's comment had also argued for checking on read paths, so two bots pointed at the same gap. This guide did not check for a follow-up issue.
A check on a value the code produced itself#
In an AReaL pull request that made PPO loss aggregation configurable, gemini-code-assist's review objected to a validation already in the diff: "checking torch.any(sequence_lengths < 0) inside an if statement triggers a GPU-to-CPU synchronization on every microbatch." It added: "It is recommended to remove this redundant check from the hot path to avoid degrading training throughput." Review
The lengths come from cu_seqlens, offsets the training code's own packer builds. The author's commit aeb6391, "perf(utils): avoid loss aggregation device sync", says: "Trust packer-owned cumulative sequence lengths and provide exact repeat output sizes so aggregation does not synchronize to discover device-side values or shapes." The merged _sequence_sums keeps the shape checks, which read host-side metadata, and drops the value check. It also passes output_size to torch.repeat_interleave, which, its documentation says, avoids the synchronization needed to compute the output shape. The pull request merged on 12 October 2026.
No boundary sits between the packer and the loss function, so a value check there costs a device sync per microbatch and buys nothing. Home Assistant wrote the same rule into its agent guidance for entity actions: "avoid requesting redundant defensive checks for fields already enforced by Home Assistant validation schemas and entity filters; only request extra guards when values bypass validation or are transformed unsafely." Integration guidance If a reviewer keeps asking for checks your schemas enforce, an instruction like that is the fix; the custom review rules guide shows how.
Decide from where the value came from#
| What you find | Response |
|---|---|
| The value comes from a less trusted party and nothing checks it before it is stored, executed or rendered | Change: validate at the boundary with an allowlist |
| The boundary check exists but misses a field or a path that carries the same value | Change, as with the L2 backend icons |
| A schema, parser or framework filter already enforces the rule on every path in | Dismiss, naming the check |
| The value is produced by your own code, such as offsets a packer computed | Dismiss; keep cheap structural checks if they catch programming errors |
| The bot wants the check moved or its failure mode changed | Follow the project's existing contract for that kind of value |
| Data stored before the check was added | Defer to a follow-up with its own owner and migration |
| You cannot tell whether some path skips the upstream check | Write a test that sends the bad value through that path |
A "validated upstream" dismissal is only as good as the upstream check. Name it in the reply, and use a test of what the reviewer could see when the check lives outside the diff.