Hi forestadmin team! Hope you are all doing well!
I’m totally aware that it is very likely that I introduced that bug in the codebase myself.
Sorry!
Feature(s) impacted
Smart fields in agent nodejs
Observed behavior
When I have a collection with smartfields, and set a filter which matches zero records in the UI, the smart field handler is still called, with zero records.
This causes a crash in the route handler, because I’m doing the following
{
columnType: 'Number',
dependencies: ['id'],
getValues: async (records, context) => {
// ^---- this is an empty array!
const rows = await context.collection.nativeDriver.rawQuery(`
SELECT blabla FROM whatever WHERE modelId IN (:recordIds)`,
{ recordIds: records.map(r => r.id) }
);
return records.map(...)
}
Expected behavior
As there is nothing to compute, the handler should not be called.
The workaround on customer side is trivial but I need to repeat it on all smart fields.
I would love to avoid that
if (!records.length) return []
Failure Logs
=>
Context
- Project name: roundtable
- Team name: …
- Environment name: prod
- Agent (forest package) name & version: agent nodejs 1.36.10
- Database type: sql
- Recent changes made on your end if any: