HarperFast / HarperFast/harper
Improve schema type mismatch error: 'must be a Buffer or Uint8Array' is unclear
- Dominant language
- JavaScript
- Stars
- 89
- Forks
- 10
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 200
Description
## Problem
When inserting a record where a property value doesn't match the schema's binary type, the error message is:
```
Error: Value "[us-east-1 us-west-2]" in property regions must be a Buffer or Uint8Array
```
This is confusing because:
1. Users don't typically declare schema fields as `Buffer`/`Uint8Array` — it's not obvious which JSON schema type maps to this
2. The error doesn't suggest what the correct value format should be
3. Users see the raw internal type name rather than a schema-friendly description
## Location
`core/resources/Table.ts:3180`
```ts
`Value ${stringify(value)} in property ${name} must be a Buffer or Uint8Array`
```
## Proposed
Improve the error message to:
- Indicate which schema type the property was declared as (e.g., `blob`, `binary`)
- Suggest correct input format (e.g., base64-encoded string, byte array)
- Avoid leaking internal type names like `Buffer`/`Uint8Array` in user-facing errors
🤖 Filed by Claude on behalf of Kris.
Contributor guide
Assessment
This issue has not been assessed yet.