Page MenuHomePhabricator

Audit and tighten WFFunction.maybeValidateInternal
Closed, ResolvedPublic

Description

maybeValidateInternal in src/transpilation/WFFunction.js carries three T413840-tagged design questions (lines 28, 39, 44) about argument validation correctness:

  • The function only runs validation when the argument is a WFObject; other WFBase subclasses are silently skipped. Unclear whether WFList, WFFunctionCall, etc. should also flow through.
  • When the validation function on a type is not a Z9/reference, the function returns silently. Unclear whether this should be an error (definitely user-defined, but not in a form we can run) or whether silent skip is correct.
  • The "is this a built-in validator we can skip" check is a heuristic on numeric ZID ranges (< 400, or 500 <= ZID < 10000). Brittle; should consult the actual built-in registry.

This is correctness/design work, not performance.

Desired behavior/Acceptance criteria

  • Decide and document which WFBase subclasses need validation; widen the gate or document the omission.
  • Decide and document non-Z9 validation function behaviour; convert silent skip to a proper Z5 if appropriate.
  • Replace the numeric-ZID heuristic with a lookup against the actual builtin/validator registry.
  • All existing tests pass; new tests for any behavioural changes.

Details

Related Changes in Gerrit:
Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
maybeValidateInternal(): throw error on inline validatorrepos/abstract-wiki/wikifunctions/function-orchestrator!681ecarggrace/T426335/throw-on-inline-validatormain
Customize query in GitLab

Event Timeline

For:

The "is this a built-in validator we can skip" check is a heuristic on numeric ZID ranges (< 400, or 500 <= ZID < 10000). Brittle; should consult the actual built-in registry.

  • since there's a getFunction( ZID ) that returns null if the ZID isn't in the map, in maybeValidateInternal() we could do smth like:
jsconst { getFunction } = require( './builtins.js' );
// ...
if ( getFunction( validationZID ) !== null ) { return; }
  • If it's in the builtins registry, it's a built-in validator and we can skip. If it's not, we run it. (Rather than relying on ZID ranges).

Update:
After further investigation replacing this may be more complicated. getFunction from builtins.js covers active built-in implementations, and isBuiltInType from utils.js covers built-in types, but neither covers Z831 (Validate against schema), which appears in test fixtures as a Z4K3 validator but has no active implementation — its only implementation Z931 is explicitly unregistered in builtins.js because schema validation is deprecated(?). The heuristic currently skips Z831 via the >= 500 && < 10000 range.

The function only runs validation when the argument is a WFObject; other WFBase subclasses are silently skipped. Unclear whether WFList, WFFunctionCall, etc. should also flow through.

  • Only skipping WFObject makes sense to me bc the others are more primitive-y. But it seems like WFList does have a type, which means it could be silent-skipped.

Next step: Do any Types in Prod have both a list-based (or other non-WFObject) structure and a meaningful Z4K3 validator? If yes, the guard is a correctness gap; needs team decision. (If not, I guess it's fine as is.)

When the validation function on a type is not a Z9/reference, the function returns silently. Unclear whether this should be an error (definitely user-defined, but not in a form we can run) or whether silent skip is correct.

  • I'm thinking 'no' to silent-skip bc it is misleading? Maybe proper Z5 error.

Next step: Team decision -> the decision is to throw an error instead of silently skipping; also we have no inlines in Prod

Change #1297142 had a related patch set uploaded (by Jforrester; author: Jforrester):

[operations/deployment-charts@master] wikifunctions: Upgrade orchestrator from 2026-05-19-223625 to 2026-06-03-020126

https://gerrit.wikimedia.org/r/1297142

Change #1297142 merged by jenkins-bot:

[operations/deployment-charts@master] wikifunctions: Upgrade orchestrator from 2026-05-19-223625 to 2026-06-03-020126

https://gerrit.wikimedia.org/r/1297142