Skip to content

fix(validators): isSchemaKind no longer accepts inherited prototype keys#14

Merged
ralyodio merged 1 commit into
profullstack:masterfrom
quappefeeder:fix/schema-kind-own-property
Jun 12, 2026
Merged

fix(validators): isSchemaKind no longer accepts inherited prototype keys#14
ralyodio merged 1 commit into
profullstack:masterfrom
quappefeeder:fix/schema-kind-own-property

Conversation

@quappefeeder

Copy link
Copy Markdown
Contributor

Fixes #13

Summary

isSchemaKind used value in schemas, which walks the prototype chain — inherited keys like toString/constructor passed assertSchemaKind and then crashed ajv.compile with a misleading schema must be object or boolean error (reachable via the logicsrc-validate CLI).

Changes

  • Object.hasOwn(schemas, value) own-property check
  • unit tests: rejects toString/constructor/valueOf/hasOwnProperty with the intended Unknown schema kind error; every real schema kind still accepted

Testing

npx vitest run   # in packages/validators
# Test Files  2 passed (2)
#      Tests  8 passed (8)

Applied via the ugig gig — ugig user liudong-design.

'value in schemas' walks the prototype chain, so inherited keys like
"toString" passed assertSchemaKind and then crashed ajv.compile with a
misleading 'schema must be object or boolean' error (e.g. via the CLI).
Use Object.hasOwn for an own-property check.

Adds unit tests rejecting prototype keys and asserting every real
schema kind still passes.

Fixes profullstack#13
@ralyodio ralyodio merged commit 3d4345b into profullstack:master Jun 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

validators: isSchemaKind accepts inherited Object.prototype keys ("toString", "constructor", …), crashing the CLI with a misleading error

2 participants