fix(frontend): skip format/pattern validation for $var/$res/$jsonvar references in ArgInput

A resource field with a `pattern` constraint (e.g. the gpg_key.private_key
field, whose pattern enforces a `-----BEGIN PGP PRIVATE KEY BLOCK-----`
prefix) rejects values like `$var:u/me/gpg-private-key` with an "invalid
format" error in the resource editor — even though `$var:`/`$res:`/`$jsonvar:`
are placeholders the backend resolves at runtime, not the actual string
that needs to match the regex.

Bail out of all format/pattern checks (email, ipv4, ipv6, uuid, custom
pattern) when the value is one of these references. Required/numeric
bounds/array checks still apply since they're shape-level, not regex.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-05-22 06:44:47 +00:00
co-authored by Claude Opus 4.7
parent b0f68c73af
commit 6f9a0e3765
@@ -406,6 +406,15 @@
if (nullable && emptyString(v)) {
error = ''
valid && (valid = true)
} else if (
typeof v === 'string' &&
(v.startsWith('$var:') || v.startsWith('$res:') || v.startsWith('$jsonvar:'))
) {
// $var/$res/$jsonvar are placeholders resolved at runtime; the literal
// string won't match format constraints (email/ipv4/uuid/custom pattern),
// so format-checking it produces a false-positive "invalid format" error.
error = ''
!valid && (valid = true)
} else if (required && (v == undefined || v == null || v === '') && inputCat != 'object') {
error = 'Required'
valid && (valid = false)