Discourse Automation Plugin failing with an 'internal server error'

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.

The following is the error that appears:

PG::NotNullViolation (ERROR:  null value in column "total_time" of relation "discourse_automation_stats" violates not-null constraint
DETAIL:  Failing row contains (18, 8, 2025-04-10, 2025-04-10 07:34:42.740189, null, null, null, null, 1).
)
lib/mini_sql_multisite_connection.rb:109:in `run'
lib/plugin/instance.rb:609:in `block in on'
lib/discourse_event.rb:12:in `block in trigger'
lib/discourse_event.rb:12:in `trigger'
app/models/group.rb:869:in `trigger_user_added_event'
app/models/group.rb:838:in `add'
app/controllers/groups_controller.rb:502:in `block in handle_membership_request'
app/controllers/groups_controller.rb:500: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'

I suspect this has to do with the new changes to the discourse_automation_stats table mentioned here:

Thanks!

1 Like

Thanks for the report. I think you have an other error, but the stat code we added is hiding it.

That should fix it:

And then we should be able to see the actual error.

1 Like

Thanks!

Does this mean after the update, I need to get the actual error?

1 Like

Yes please, even though I suspect from here, you might be able to fix it yourself.

2 Likes