Feature(s) impacted
Model:
...
languages: {
type: [
{
value: {
lang: String,
kind: String,
},
_id: false,
},
],
required: true,
default: [],
},
...
configuration
...
agent.addDataSource(
createMongooseDataSource(connection, {
flattenMode: 'manual',
flattenOptions: {
offices: { asFields: ['address', 'postbox'], asModels: ['lawyers'] },
lawyers: {
asFields: ['billing', 'languages', 'experience', 'education', 'practiceAreas', 'publications'],
asModels: ['languages', 'experience', 'education', 'practiceAreas', 'publications'],
},
},
})
);
...
leads to forestadmin-schema.json
:
...
{
"actions": [],
"fields": [
{
"defaultValue": null,
"enums": null,
"field": "_id",
"integration": null,
"inverseOf": null,
"isFilterable": true,
"isPrimaryKey": true,
"isReadOnly": true,
"isRequired": false,
"isSortable": true,
"isVirtual": false,
"reference": null,
"type": "String",
"validations": []
},
{
"defaultValue": null,
"enums": null,
"field": "parent",
"integration": null,
"inverseOf": "languages",
"isFilterable": true,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": true,
"isSortable": true,
"isVirtual": false,
"reference": "lawyers._id",
"relationship": "BelongsTo",
"type": "String",
"validations": [{"type": "is present", "message": "Field is required"}]
},
{
"defaultValue": null,
"enums": null,
"field": "value@@@kind",
"integration": null,
"inverseOf": null,
"isFilterable": true,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": false,
"isSortable": true,
"isVirtual": false,
"reference": null,
"type": "String",
"validations": []
},
{
"defaultValue": null,
"enums": null,
"field": "value@@@lang",
"integration": null,
"inverseOf": null,
"isFilterable": true,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": false,
"isSortable": true,
"isVirtual": false,
"reference": null,
"type": "String",
"validations": []
}
],
"icon": null,
"integration": null,
"isReadOnly": false,
"isSearchable": true,
"isVirtual": false,
"name": "lawyers_languages",
"onlyForRelationships": false,
"paginationType": "page",
"segments": []
},
...
Observed behavior
Creation of new lawyer language in the UI leads to an error notification, but the operation is successful, if I refresh.
Expected behavior
No error notification.
Failure Logs
Cannot read properties of undefined (reading 'type')
TypeError: Cannot read properties of undefined (reading 'type')
at BinaryCollectionDecorator.convertValue (/Users/davidroegiers/Jurata/jurata-next/forest-2/node_modules/@forestadmin/datasource-customizer/src/decorators/binary/collection.ts:182:16)
at /Users/davidroegiers/Jurata/jurata-next/forest-2/node_modules/@forestadmin/datasource-customizer/src/decorators/binary/collection.ts:142:20
at Array.map (<anonymous>)
at BinaryCollectionDecorator.convertRecord (/Users/davidroegiers/Jurata/jurata-next/forest-2/node_modules/@forestadmin/datasource-customizer/src/decorators/binary/collection.ts:140:46)
at /Users/davidroegiers/Jurata/jurata-next/forest-2/node_modules/@forestadmin/datasource-customizer/src/decorators/binary/collection.ts:102:61
at Array.map (<anonymous>)
at BinaryCollectionDecorator.create (/Users/davidroegiers/Jurata/jurata-next/forest-2/node_modules/@forestadmin/datasource-customizer/src/decorators/binary/collection.ts:102:42)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async PublicationFieldCollectionDecorator.create (/Users/davidroegiers/Jurata/jurata-next/forest-2/node_modules/@forestadmin/datasource-customizer/src/decorators/publication-field/collection.ts:34:21)
at async RenameFieldCollectionDecorator.create (/Users/davidroegiers/Jurata/jurata-next/forest-2/node_modules/@forestadmin/datasource-customizer/src/decorators/rename-field/collection.ts:101:24)
Context
- Project name: jurata-2
- Team name: jurata
- Environment name: staging
- Agent (forest package) name & version: “node_modules/@forestadmin/agent”: {
“version”: “1.13.1”, - Database type: mongoose
- Recent changes made on your end if any: unknown, it used to work.