---
title: "Does this input need validating, or was it checked upstream? | Proofline"
description: "Validate a value where it crosses from a less trusted party into code that stores it, executes it or shows it to someone else."
url: https://proofline.sh/learn/ai-review-input-validation-comment/
---

[Learning center](/learn/)

# Does this input need validating, or was it checked upstream?

Validate a value where it crosses from a less trusted party into code that stores it, executes it or shows it to someone else. When the reviewer asks for a check on a value your own code produced, or one a schema or framework already enforced on the way in, dismiss the comment and name that check. When the boundary is right but the place or coverage is wrong, judge the comment at that boundary.

Code review The Proofline team November 22, 2026 5 min read

## 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](https://cheatsheetseries.owasp.org/cheatsheets/Input_Validation_Cheat_Sheet.html) 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](https://github.com/gpustack/gpustack/pull/6391) 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](https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/javascript) 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](https://github.com/gpustack/gpustack/pull/6391#discussion_r4237283103) 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](https://github.com/gpustack/gpustack/pull/6391#issuecomment-6096523745) 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](https://github.com/gpustack/gpustack/pull/6391#discussion_r4237287783) 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](https://github.com/areal-project/AReaL/pull/1546#pullrequestreview-4728274448)

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`](https://pytorch.org/docs/stable/generated/torch.repeat_interleave.html), 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](https://github.com/home-assistant/core/blob/dev/.claude/skills/ha-integration-knowledge/SKILL.md) If a reviewer keeps asking for checks your schemas enforce, an instruction like that is the fix; the [custom review rules guide](/learn/write-custom-ai-code-review-rules/) 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](/learn/test-reviewer-context-beyond-diff/) when the check lives outside the diff.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Does your code reviewer read beyond the diff? Build a test pull request](/learn/test-reviewer-context-beyond-diff/)
    
    Code review The Proofline team November 20, 2026 4 min read
    
-   ### [How to write custom AI code review rules for a repository](/learn/write-custom-ai-code-review-rules/)
    
    Code review The Proofline team November 18, 2026 3 min read
