mirror of
https://github.com/xtr-dev/payload-automation.git
synced 2025-12-10 17:03:22 +00:00
- Add console.log statements that will ALWAYS appear if hooks are called - Trace WorkflowExecutor creation and method availability - Log every step of hook execution pipeline - This will help identify exactly where the execution is failing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
3.0 KiB
3.0 KiB
🚨 CRITICAL: Configuration Field Name Issue Found
❌ The Root Problem
Your plugin configuration is using the wrong field name!
What You're Probably Using (WRONG):
automationPlugin({
collections: ['orders', 'users', 'products'], // ❌ Wrong field name
steps: [...],
})
What You MUST Use (CORRECT):
automationPlugin({
collectionTriggers: { // ✅ Correct field name
'orders': true,
'users': true,
'products': true
},
steps: [...],
})
🔧 Immediate Fix Required
Update your payload.config.ts file:
import { automationPlugin } from '@xtr-dev/payload-automation'
export default buildConfig({
// ... your other config
plugins: [
automationPlugin({
collectionTriggers: { // ← CHANGE THIS FIELD NAME
orders: true, // Enable all hooks (create, read, update, delete)
users: true,
products: true
},
steps: [
// ... your step configurations
]
})
]
})
🎯 Why This Fixes Everything
- Hook Registration: The plugin only registers hooks for collections listed in
collectionTriggers - No Hooks = No Execution: If
collectionTriggersis empty/missing, no hooks get registered - Silent Failure: The plugin logs "No collection triggers configured" and returns early
🔍 Advanced Configuration Options
You can also be more specific about which operations trigger workflows:
automationPlugin({
collectionTriggers: {
orders: {
update: true, // Only trigger on updates
create: true // Only trigger on creates
// read and delete are false by default
},
users: true // Enable all operations
},
// ...
})
✅ Expected Results After Fix
Once you update your configuration and restart:
-
Plugin logs will show:
Starting collection hook registration Collection hooks registered successfully - collectionSlug: "orders" -
Hook counts will be > 0:
payload.collections.orders.config.hooks.afterChange.length // Should return a number > 0 -
Workflow execution will work:
- "AUTOMATION PLUGIN: Collection hook triggered" messages
- Workflow runs created in database
- Jobs processing successfully
🆘 If Still Not Working
If you fix the configuration and it still doesn't work:
-
Check your exact collection slugs:
console.log('Available collections:', Object.keys(payload.collections)) -
Verify case sensitivity: Collection slugs are case-sensitive
- Use exactly what appears in
Object.keys(payload.collections)
- Use exactly what appears in
-
Restart completely:
- Stop dev server
- Clear any caches
- Restart with new configuration
This configuration field name issue explains why no hooks were being registered, despite the plugin loading successfully. The v0.0.16 bug fix was valid, but this configuration issue was preventing hooks from being registered in the first place.