# Unexpected error in Discourse Plugin CI

**URL:** https://meta.discourse.org/t/unexpected-error-in-discourse-plugin-ci/378165
**Category:** Development
**Created:** [August 11, 2025, 3:26pm UTC](https://meta.discourse.org/t/unexpected-error-in-discourse-plugin-ci/378165 "2025-08-11T15:26:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 11, 2025, 3:26pm UTC](https://meta.discourse.org/t/unexpected-error-in-discourse-plugin-ci/378165/1 "2025-08-11T15:26:14Z")

</div>

UPDATE: @NateDhaliwal rightfully points out my accessing the DB in `after_initializer` may break the rules - I was just lucky for a long time.

I’m going to make some changes.

I’m getting:

```plaintext
ActiveRecord::NoDatabaseError: We could not find your database: discourse_test. Available database configurations can be found in config/database.yml. (ActiveRecord::NoDatabaseError)

```

> **detail**
>
> ```plaintext
> rake aborted!
> ActiveRecord::NoDatabaseError: We could not find your database: discourse_test. Available database configurations can be found in config/database.yml. (ActiveRecord::NoDatabaseError)
> To resolve this error:
> - Did you not create the database, or did you delete it? To create the database, run:
> bin/rails db:create
> - Has the database name changed? Verify that config/database.yml contains the correct database name.
> /__w/discourse-chatbot/discourse-chatbot/config/initializers/000-pg-connection-debug.rb:14:in `rescue in new_client'
> /__w/discourse-chatbot/discourse-chatbot/config/initializers/000-pg-connection-debug.rb:4:in `new_client'
> 
> ```

in my [github workflow](https://github.com/merefield/discourse-chatbot/actions/runs/16884264223/job/47827783812)

Has something changed around the standard plugin CI workflow I wasn’t aware of?

I’m still following:

> [@Setup Continuous Integration using GitHub Actions](https://meta.discourse.org/t/setup-continuous-integration-using-github-actions/240150):
>
> mag Overview To build a robust extension for Discourse, it can be wise to include Continuous Integration (CI) into your plugin or theme-component. This will help to detect errors early on and lessen the chances of bugs in your code. Setting up a CI workflow using [GitHub Actions](https://github.com/features/actions) to automate builds and testing is an approach the Discourse team uses on all our components, and we recommend you do the same. gear Setting it up To add automated workflows for GitHub actions to detect, you need to …

and using v1

There is no code of mine running up to this point (except gem installs) and this PR has in any case just minor config changes.

PS Looks like it’s been evolving recently: [History for .github/workflows/discourse-plugin.yml - discourse/.github · GitHub](https://github.com/discourse/.github/commits/main/.github/workflows/discourse-plugin.yml)

---

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [August 11, 2025, 10:53pm UTC](https://meta.discourse.org/t/unexpected-error-in-discourse-plugin-ci/378165/2 "2025-08-11T22:53:25Z")

</div>

Not 100% sure, but I _think_ it happens if you use ActiveRecord through things like User, etc openly, e.g. not in `on()` or in a job but just in `after_initialize`.

I encountered this too not long ago… IIRC I had to ask AI for this; I moved the code to a scheduled job and it was fine after that.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 12, 2025, 1:19pm UTC](https://meta.discourse.org/t/unexpected-error-in-discourse-plugin-ci/378165/4 "2025-08-12T13:19:53Z")

</div>

Apologies, on second look it _does_ seem to be failing on my code, but I am accessing it in `after_initialize`

Looks like the rules might have changed:

```plaintext
user_count = User.count

```

doesn’t look legal in an initializer anymore (perhaps it was always bad practice)

thanks for the suggestion! 👏

I think you are absolutely right that I should move this to a job and run it once. 👍

---

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [August 13, 2025, 12:07am UTC](https://meta.discourse.org/t/unexpected-error-in-discourse-plugin-ci/378165/5 "2025-08-13T00:07:32Z")

</div>

No problem, glad you got it working!
