The issue began with an ‘internal server error’ in the Discourse Automation Plugin after an update, specifically when approving users to a group with an automation script configured to send PMs. The error stemmed from a database constraint violation in discourse_automation_stats due to null values in the total_time column, linked to recent changes in the plugin sam. j.jaffeux identified that the new stats code was masking the actual error and submitted a fix PR #32254. After applying the fix, gassim encountered a new 422 Unprocessable Entity error during group approval, but noted that the automation still functioned (user added, PM sent). The error only appeared for non-admin group owners, not admins. Further investigation revealed the issue persisted in logs as ActiveRecord::RecordNotSaved, suggesting a topic-related conflict. j.jaffeux questioned the connection to automation, as the error occurred during manual group approval. Ultimately, gassim resolved the issue by disabling the automation, clearing browser cache, and re-enabling it — after which all errors disappeared. j.jaffeux expressed surprise but accepted the resolution. The thread concludes with gratitude from gassim.
Before the latest update, there was an automation using the Automation Plugin that does the following (which was tested and it was working successfully without any changes):
Script: Send pms
When: “User added to group”
Tracked group: “a group that requires group owner to ‘approve requests’ first”
Script Options: one PM (tested and it worked successfully).
Currently, on version: 3.5.0.beta3-dev(231e9ca99a) it now shows “internal server error” when attempting to approve the users.
This error “unprocessable entity” doesn’t appear when the admin account is used to accept the group request, but it’s appearing to a non-admin group owner user (even with 1 and 2 happening successfully now for both admin/non-admin).
It seems now we are talking about a new issue (given those above are now working but only that the result isn’t clear when it’s blocked with this new issue)…
even the server error logs changed:
info log
ActiveRecord::RecordNotSaved (Something has gone wrong. Perhaps this topic was closed or deleted while you were looking at it?)
lib/post_creator.rb:238:in `create!'
app/controllers/groups_controller.rb:523:in `handle_membership_request'
app/controllers/application_controller.rb:427:in `block in with_resolved_locale'
app/controllers/application_controller.rb:427:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:35:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:410:in `call'
lib/middleware/csp_script_nonce_injector.rb:12:in `call'
config/initializers/008-rack-cors.rb:26:in `call'
lib/middleware/default_headers.rb:13:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
lib/middleware/processing_request.rb:12:in `call'
lib/middleware/request_tracker.rb:385:in `call'
Im sorry but Im very confused how this is related to the op. You don’t get this error through automation right? This is a direct action you are doing in the admin as far as I can tell.
Hi again!
Thank you for spending your time on this one so I think it’s now resolved. Initially, the error only appeared after we activated the automation (first error posted in first post), and then after your fix the error disappeared but the logs showed a different error as explained above.
The errors disappeared after I did the following:
Turned off the automation
Cleared the browser cache
Turned the automation back on
After turning the automation on/off and clearing cache all the errors disappeared. Thank you!