Feature(s) impacted
Out-of-the-box one-to-many relationships based on a mongoose schema.
I have created a minimal viable repo to showcase the bug. Tip of master.
Observed behavior
- Create a lawyer without an office (office is not a required property).
- Set the office reference to
name
- Open the previously created lawyer.
- Error.
Expected behavior
- No error.
Failure Logs
warning: [404] GET /forest/lawyers - 14ms
===== An exception was raised =====
GET /forest/lawyers?{
timezone: Europe/Zurich,
fields[lawyers]: _id,office__manyToOne,createdAt,firstName,lastName,updatedAt,
fields[office__manyToOne]: name,
page[number]: 1,
page[size]: 15,
sort: -_id
}
Missing one of expected fields: '_id'
Error: Missing one of expected fields: '_id'
at Function.packId (/Users/davidroegiers/Jurata/forest-admin-bug-reports/node_modules/@forestadmin/agent/src/utils/id.ts:25:13)
at Object.beforeSerialize (/Users/davidroegiers/Jurata/forest-admin-bug-reports/node_modules/@forestadmin/agent/src/services/serializer.ts:84:33)
at JSONAPISerializer.serializeResource (/Users/davidroegiers/Jurata/forest-admin-bug-reports/node_modules/json-api-serializer/lib/JSONAPISerializer.js:565:22)
at JSONAPISerializer.serializeRelationship (/Users/davidroegiers/Jurata/forest-admin-bug-reports/node_modules/json-api-serializer/lib/JSONAPISerializer.js:800:39)
at /Users/davidroegiers/Jurata/forest-admin-bug-reports/node_modules/json-api-serializer/lib/JSONAPISerializer.js:693:20
at Array.forEach (<anonymous>)
at JSONAPISerializer.serializeRelationships (/Users/davidroegiers/Jurata/forest-admin-bug-reports/node_modules/json-api-serializer/lib/JSONAPISerializer.js:681:40)
at JSONAPISerializer.serializeResource (/Users/davidroegiers/Jurata/forest-admin-bug-reports/node_modules/json-api-serializer/lib/JSONAPISerializer.js:572:27)
at /Users/davidroegiers/Jurata/forest-admin-bug-reports/node_modules/json-api-serializer/lib/JSONAPISerializer.js:560:14
at Array.map (<anonymous>)
===================================
Context
See repo.