When upgrating to v8 , smart action change hooks doesn’t work.
Actual behavior
change: {
[‘Recherche fournisseur (3 lettres minimum)’]: ({ fields, record }) => {
if (fields[‘Recherche fournisseur (3 lettres minimum)’].value.length > 2) {
return axios.get(${API_URL}/forest_admin/sage_providers
, {
headers: {
‘Authorization’: Bearer ${process.env.ACCESS_TOKEN}
,
‘X-CURRENT-USER-EMAIL’: process.env.SERVICE_EMAIL
},
params: {
place_id: ‘’,
provider_name: fields[‘Recherche fournisseur (3 lettres minimum)’].value,
siret: ‘’,
matricule: ‘’
}
}).then(res => {
if (res.data && res.data.length > 0) {
fields.find(f => f.field === ‘Fournisseur’).enums = res.data.map(provider => ${provider.matricule} - ${provider.raison_sociale} - ${provider.site_ville}
)
}
return fields;
});
}
return fields;
}
}
Failure Logs
[forest] Error in smart action change hook: hook must be a function
{
“stack”: “Error: hook must be a function\n at SmartActionHookService._callee$ (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\services\smart-action-hook-service.js:78:23)\n at tryCatch (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\regenerator-runtime\runtime.js:63:40)\n at Generator.invoke [as _invoke] (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\regenerator-runtime\runtime.js:293:22)\n at Generator.next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\regenerator-runtime\runtime.js:118:21)\n at asyncGeneratorStep (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)\n at _next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)\n at C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:32:7\n at new Promise ()\n at SmartActionHookService. (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:21:12)\n at SmartActionHookService.getResponse (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\services\smart-action-hook-service.js:138:29)\n at _callee2$ (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\routes\actions.js:117:56)\n at tryCatch (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\regenerator-runtime\runtime.js:63:40)\n at Generator.invoke [as _invoke] (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\regenerator-runtime\runtime.js:293:22)\n at Generator.next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\regenerator-runtime\runtime.js:118:21)\n at asyncGeneratorStep (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)\n at _next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)\n at C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:32:7\n at new Promise ()\n at C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:21:12\n at C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\routes\actions.js:144:24\n at Layer.handle [as handle_request] (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\express\lib\router\layer.js:95:5)\n at
next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\express\lib\router\route.js:137:13)\n at dispatch (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:46:24)\n at next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:51:24)\n at ipAuthorizer (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\middlewares\ip-whitelist.js:25:12)\n at C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\services\auth.js:61:10\n at dispatch (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:63:32)\n at next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:51:24)\n at ensureAuthenticated (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\services\auth.js:31:10)\n at dispatch (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:63:32)\n at middleware (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:76:16)\n at C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:15:47\n at Layer.handle [as handle_request] (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\express\lib\router\layer.js:95:5)\n at next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\express\lib\router\route.js:137:13)”
}
POST /forest/actions/ajouter-un-contrat-d-immeuble/hooks/change?timezone=Europe%2FParis 500 37 - 7.295 ms
[forest] Error in smart action change hook: hook must be a function
{
“stack”: “Error: hook must be a function\n at SmartActionHookService._callee$ (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\services\smart-action-hook-service.js:78:23)\n at tryCatch (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\regenerator-runtime\runtime.js:63:40)\n at Generator.invoke [as _invoke] (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\regenerator-runtime\runtime.js:293:22)\n at Generator.next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\regenerator-runtime\runtime.js:118:21)\n at asyncGeneratorStep (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)\n at _next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)\n at C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:32:7\n at new Promise ()\n at SmartActionHookService. (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:21:12)\n at SmartActionHookService.getResponse (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\services\smart-action-hook-service.js:138:29)\n at _callee2$ (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\routes\actions.js:117:56)\n at tryCatch (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\regenerator-runtime\runtime.js:63:40)\n at Generator.invoke [as _invoke] (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\regenerator-runtime\runtime.js:293:22)\n at Generator.next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\regenerator-runtime\runtime.js:118:21)\n at asyncGeneratorStep (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)\n at _next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)\n at C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:32:7\n at new Promise ()\n at C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\node_modules\@babel\runtime\helpers\asyncToGenerator.js:21:12\n at C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\routes\actions.js:144:24\n at Layer.handle [as handle_request] (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\express\lib\router\layer.js:95:5)\n at
next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\express\lib\router\route.js:137:13)\n at dispatch (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:46:24)\n at next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:51:24)\n at ipAuthorizer (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\middlewares\ip-whitelist.js:25:12)\n at C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\services\auth.js:61:10\n at dispatch (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:63:32)\n at next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:51:24)\n at ensureAuthenticated (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\forest-express-sequelize\node_modules\forest-express\dist\services\auth.js:31:10)\n at dispatch (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:63:32)\n at middleware (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:76:16)\n at C:\DEV\git\sergic\syndic-one-rebirth\node_modules\compose-middleware\lib\index.js:15:47\n at Layer.handle [as handle_request] (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\express\lib\router\layer.js:95:5)\n at next (C:\DEV\git\sergic\syndic-one-rebirth\node_modules\express\lib\router\route.js:137:13)”
Context
- Project name: Sergic
- Team name: Gestion
- Environment name: development
- Agent (forest package) name & version: 7.12.3 to 8.5.14
- Database type: Postgre
- Recent changes made on your end if any: …