loopbackio / loopbackio/loopback-next
Model type "buffer" is not working
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
Describe the bug
Getting below error after creating model with buffer type property.
Request POST /tests failed with status code 500. Error: type must be JSONType or JSONType[]: buffer
Model Property (Entity):
@property({
type: 'buffer',
})
image?: Buffer;
Steps to reproduce:
- Create new app: lb4 app
- Add new model with buffer type property (not required field): lb4 model
- Add any type of db: lb4 datasource
- Create repository: lb4 repository
- Create controller with all CRUD operations: lb4 controller
- Test POST request on explorer
Logs
Request POST /tests failed with status code 500. Error: type must be JSONType or JSONType[]: buffer
at getJSONTypes (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/dataType.ts:36:9)
at getSchemaTypes (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/dataType.ts:20:17)
at typeAndKeywords (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:159:31)
at subSchemaObjCode (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:147:3)
at subschemaCode (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:124:7)
at KeywordCxt.subschema (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:491:5)
at applyPropertySchema (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/vocabularies/applicator/properties.ts:45:11)
at Object.code (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/vocabularies/applicator/properties.ts:32:9)
at keywordCode (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:523:9)
at /Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:265:9
at CodeGen.code (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/codegen/index.ts:525:33)
at CodeGen.block (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/codegen/index.ts:680:20)
at iterateKeywords (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:262:7)
at groupKeywords (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:241:7)
at /Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:233:38
at CodeGen.code (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/codegen/index.ts:525:33)
Additional information
No response
Reproduction
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open the linked reproduction and recreate the generated model, datasource, repository, controller, and POST request described in the issue. Trace the validation path that rejects the model's optional Buffer property, then add coverage showing that the POST request no longer fails with the AJV JSONType error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100