HarperFast / HarperFast/harper

Schema validation is inconsistent at depth: nested-object field types and nested @sealed are not enforced (typed-array elements are)

Open
#1,328 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
89
Forks
10
Avg merge
2d 6h
Merged PRs (30d)
200

Description

## Summary
Schema/type validation depth is split/inconsistent — a silent-bad-data risk:

- **Enforced:** top-level typed scalars (`total:"str"`→400) and top-level `@sealed` (undeclared top-level prop→400).
- **Enforced (deep):** typed-array element types — `tags:[1,"two",3]` on `[Int]`→400 (`property tags[*]`); nested `matrix:[[1,"x"]]` on `[[Int]]`→400.
- **NOT enforced:** nested-OBJECT field types, at any depth — `shipTo.zip:"str"` (declared Int, 1 level)→**200, stored as-is**; `meta.geo.lat:"north"` (declared Float, 2 levels)→**200, stored as-is**.
- **NOT enforced:** `@sealed` does not propagate into nested object types — an undeclared/extra prop inside a nested `@sealed` type→**200, stored** (nested `@sealed` is silently inert).

So array element types are validated recursively, but object-field types and nested `@sealed` are not — surprising and inconsistent, and a nested `@sealed` annotation looks like it enforces but does nothing.

## Root cause
`resources/Table.ts::validate` recurses `attribute.elements` (arrays) and type-checks, but for nested objects it recurses sub-properties WITHOUT type-checking the leaf; `resources/graphql.ts::connectPropertyType` copies a nested type's `.properties`/`.definition` to the field but NOT its `.sealed` flag (so the inner seal check reads a flag that's never set).

## Impact
Medium — no crash/data-loss, but wrong-typed nested fields and undeclared props inside nested `@sealed` objects are stored unchallenged; inconsistent with the array path and top-level seal.

## Suggested fix
Type-check nested-object leaves + propagate the nested `.sealed` flag in `validate`/`connectPropertyType` (make depth consistent with arrays), OR document clearly that only top-level scalars/seal + array elements are validated.

## Repro
`integrationTests/qa-scratch/schema-depth.test.ts`

---
_Found via the exploratory QA campaign (qa-explorer), scenario QA-108. Harper `001bf7b9c` (v5.1.0, main)._

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.