Skip to content

Allow to configure internal wiki provider via environment variables#23903

Open
NobodysNightmare wants to merge 1 commit into
devfrom
wiki-internal-env-config
Open

Allow to configure internal wiki provider via environment variables#23903
NobodysNightmare wants to merge 1 commit into
devfrom
wiki-internal-env-config

Conversation

@NobodysNightmare

Copy link
Copy Markdown
Contributor

@NobodysNightmare NobodysNightmare requested a review from a team June 24, 2026 06:05
@NobodysNightmare NobodysNightmare force-pushed the wiki-internal-env-config branch from 8e4ae8b to 8bb9f14 Compare June 24, 2026 06:08
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/my_page/spec/features/my/work_package_table_spec.rb[1:1:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #23903, linked for reference only):

- `rspec ./modules/my_page/spec/features/my/work_package_table_spec.rb[1:1:1]`

Treat this as a standalone task, unrelated to PR #23903. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #23903 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @NobodysNightmare to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @NobodysNightmare, and request a review from @NobodysNightmare.
On every commit, set @NobodysNightmare as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@@ -43,7 +43,10 @@ def show

def update
provider = Wikis::InternalProvider.first
provider.update!(enabled: internal_provider_params[:enabled])
unless provider.seeded_from_env?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 wait, does that mean, if we seeded an internal provider with env we cannot disable it anymore?

Edit: confirmed below. Was this a requirement I missed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit 2: I get it now, this "seeded by ENV" was kind of a red hering for me. It is more "enabled/disabled by ENV".

🟡 The change in the controller is okay, but I ask myself, if we maybe shouldn't touch the controller and just amend the update contract?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not using a contract at all 😅

But yeah, that would be the alternative. I guess a better name would be configured_by_env?

WDYT?

description: "Overwrite settings of the internal wiki provider through environment variables",
writable: false,
default: {},
format: :hash

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 I'm confused by the format. Why a hash? The only thing we actually accept here is { enabled: true|false }. So, a single boolean would do the job just fine, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly about forward-compatibility.

Essentially we didn't make enabling/disabling the internal provider a Setting so far, but we decided to introduce a Provider object that would carry the configuration. So it would be super confusing (IMO) if we had Setting.internal_provider_enabled?, but it wouldn't decide whether the internal provider was enabled, because we use InternalProvider.first.enabled? for that.

Thus I am configuring the entire internal provider through this hash. Like I configure entire external providers through a hash/array soon as well.

The thing is that right now enabled is the only thing that can be configured, but who knows what the future will hold.

end

def applicable?
!::Wikis::InternalProvider.exists?
!::Wikis::InternalProvider.exists? || Setting.internal_wiki_provider.present?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ logic here is now: we seed (force write) the internal provider, if

a) it is not here
b) it is already here, but we have an setting by ENV

Is this usually part of the logic of the seeders? honest question, I have no plan. :D The option b) somehow feels like this shouldn't be handled by a seeder.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand I'm very open here for a sensible argument, why the seeder is exactly the correct place.

I just wanted to express, that when I would be searching for this logic, my first thought wouldn't be "seeder".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you look at the EnvData::OpenIDConnect::ProviderSeeder you will see that second-half statement there as well.

I think the one thing that's ucommon here, is that we seed something that may be configured through env, but even if it isn't we want to seed it anyways. E.g. the OIDC seeder seeds nothing without env or something with env.

This one here is supposed to either make one initial seeding round or (if a specific configuration is intended) ensure a specific configuration whenever seeding.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tl; dr: I wouldn't know how to phrase the applicable? better/more logical. I am kinda open between having this a BasicData or an EnvData seeder.

My logic so far was that it's not always based on env data, but the app needs the seeded value to properly function, thus BasicData.

@NobodysNightmare NobodysNightmare force-pushed the wiki-internal-env-config branch from 8bb9f14 to 65cfc87 Compare June 24, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants