Skip to content

feat(config): show and edit the Redis database number in settings - #2053

Merged
Quick104 merged 5 commits into
Silo-Server:mainfrom
zenjabba:feat/redis-db-setting
Oct 8, 2026
Merged

Quick104 merged 5 commits into
Silo-Server:mainfrom
zenjabba:feat/redis-db-setting

Conversation

@zenjabba

@zenjabba zenjabba commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #1863
Related issue: N/A
Validation tasks: none

Admins cannot see or change the Redis database number without re-entering the whole connection URL, including its credentials. This adds a Database number field under Connection URL in Admin > Settings > Storage & Database > Redis and in the setup wizard.

Approach

The non-secret redis.db setting shows the database in use. An empty value follows the number in the saved URL; a number overrides it for every Redis client and the event bus, including the event bus’s legacy bare-address fallback. Changing it requires a restart. Editing the URL preserves the number shown in the field unless the admin clears that field, and the connection check uses both staged values.

REDIS_URL owns the whole connection when it is supplied by the environment. Both forms show its number read-only, and the wizard offers View so it remains inspectable and checkable. Apple, Android, and Jellyfin clients need no UI changes; this is server administration. The settings API documentation is updated. User-manual updates are tracked in Silo-Server/siloserver.org#82.

Dependency: #1859 has merged. The branch merges main, so its diff against main holds only the database-number change.

Validation

  • Go build, formatting, vet, changed-line lint, and all contract, fixture, and documentation checks passed. The full Go suite passed (173 tested packages), including after the bare-address fix. An earlier run hit the existing transcode session-tracking test's 250 ms timeout; the same test also failed in repeated baseline runs.
  • Web lint passed with existing warnings; formatting, build, bundle budget, and the full web suite passed (745 files, 5,843 tests).
  • Focused Go checks passed for configuration, Redis clients/event bus, settings handlers, node configuration, and startup. Redis and configuration tests also passed with the race detector. Protocol tests verify database selection and channel scope for legacy bare addresses and reject invalid database overrides before connecting. The connection-check test now uses the production Redis client against a test RESP server.
  • In an empty local Docker deployment, Chromium showed the effective database number in both forms. Editing 3 to 5, checking the connection, saving, and reloading retained 5 without re-entering the URL. After restart, effective settings reported 5 and event subscribers used @db5 channels.
  • Review fix 4b93d049e: in the setup wizard, emptying the URL and typing it again no longer drops the database number. Regression tests in redisDraft.test.ts and StorageStep.test.tsx fail before the fix and pass after it; the redisDraft, InfrastructureSettings, and StorageStep suites pass, along with prettier, eslint, and tsc.
  • TLS and a password-protected Sentinel deployment were not run for this PR. Existing fake-server Sentinel coverage remains in the prerequisite.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-2053/

Desktop and mobile comparisons show the new field in Admin Settings and the setup wizard, including read-only environment-managed connections. A recording shows editing, checking, saving, and reloading. Before: 3bf59f5ec; after frontend: 3ec80d1e1. The evidence page identifies the API builds and test data.

Risks

Changing the number selects a different Redis database and event-channel namespace after restart. Check the connection before saving, and keep every process of an install on the same number. REDIS_URL still takes precedence. This does not migrate Redis data or prevent saving a number the Redis server cannot provide.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code; Codex
  • Tool(s): Claude Code; Codex
  • Model(s): claude-opus-5-5[1m]; GPT-6 (identifier provided by the Codex harness)
  • Involvement: Fully AI-generated; human verification pending
  • Adversarial review: Two independent Codex reviews checked the issue requirements and repository standards. They found that the wizard hid environment-managed Redis details; the field now remains visible read-only and has a regression test. Both reviewers rechecked those changes and the bare-address database fallback fix and reported no remaining correctness findings. The possible application of the v1 feature freeze to a new key in its existing settings dictionary remains a policy judgment.
  • Review fixes: Claude Code (claude-opus-5-5[1m]) reviewed the PR with a Codex (gpt-6.1-sol) adversarial round, merged main, and wrote 4b93d049e.

Note

Add redis.db setting to show and edit the Redis database number

  • Adds a redis.db setting that overrides the database number parsed from redis.url. It is shown and editable in admin infrastructure settings and the setup wizard storage step, with read-only display when REDIS_URL manages Redis.
  • Redis clients, event buses, and Sentinel connections now build from the full RedisConfig via RedisConfig.Options, so the database override applies everywhere (redis.go, admin_settings.go).
  • Saving only stores a redis.db row when it differs from the URL's database; redundant rows are removed and invalid values (negative, fractional, nonnumeric) are rejected.
  • Risk: REDIS_URL now discards any stored redis.db override (see RedisConfig.WithBootstrapURL in admin_settings.go and watcher.go); constructor signatures for cache.NewEventBus and cache.newRedisClient changed from URL strings to RedisConfig.

Macroscope summarized 4b93d04.

Silo could only be pointed at one Redis address. After a Sentinel failover
that address is a read-only replica, and Redis writes fail until an operator
changes REDIS_URL and restarts. RedisConfig had Sentinel fields, but nothing
could set the Sentinel addresses, so that branch never ran.

A redis.url or REDIS_URL with a master_name parameter now names a Sentinel
deployment, in the go-redis failover URL form. One parser builds every Redis
client and the event bus. They ask Sentinel for the master and connect to it
on the database number in the URL, and the event bus scopes its channels to
that number as it does for a single server.

Commands reach a new master when go-redis opens its next connection. A
subscription moves only when its connection breaks, so behind Sentinel the
event bus would stay subscribed to a master that froze or dropped off the
network. For a Sentinel URL the bus reads its subscriptions with a deadline,
pings them, and redials one that has been silent for 10 seconds. Close ends
the redials before it closes the subscriptions, so it waits for the attempt
in flight and not for one redial after another. A single-server URL keeps
the receive path it had.

go-redis dials a Sentinel client's subscription with no timeout unless the
URL sets dial_timeout, so a redial to a master that is gone waits for the
kernel. The parser fills in the 5 seconds go-redis uses everywhere else.

The parser rejects what go-redis accepts in a Sentinel URL and then
mishandles: the replica options (go-redis panics on two of them, and
replica_only sends commands to a replica), a blank master name, a Sentinel
address without a host and a port, a parameter go-redis would drop without
an error, a + in a parameter, which go-redis reads as a space, and a
dial_timeout or read_timeout of 0 or less. go-redis reads such a read
timeout as no timeout, and a redial into a frozen master then never
returns. With such a dial timeout it fails every dial at once.

A single-server URL is read as before, with two exceptions. Whitespace
around it is trimmed. A URL with a part go-redis drops, after a # or in a
pair that contains a ;, is refused when master_name appears anywhere in its
query string or fragment. Such a URL was most likely meant for Sentinel and
would otherwise be used as a single-server URL for the Sentinel port.

A Sentinel URL carries the Redis password in its query string. Parse errors
no longer quote any part of the URL, and the event bus dials a value it
could not parse only when it is a host:port or a socket path made of
letters, digits, dots, hyphens and underscores. Both ended up in the log.

Subscribe now returns an error once Close has begun. Close takes the list
of subscriptions once, and a subscription confirmed after that kept its
connection, and behind Sentinel its goroutines and handler, until the
process ended.

The SentinelMaster, SentinelAddresses and SentinelPassword fields are
removed, with the two settings keys and silo.yaml import lines that fed the
master name and the password.

Refs Silo-Server#1844
The Redis database number is part of redis.url, and that setting is
write-only. An admin could not see which number an install was on, and
changing it meant entering the whole URL again, password included. The
number is what keeps installs that share one Redis server apart, so it is
a value an operator sets per install and wants to confirm.

redis.db is a new setting: empty by default, otherwise a whole number of 0
or more. When it is set it replaces the database number in the saved
redis.url, for a single-server URL and for a Sentinel URL. RedisConfig
carries it and RedisConfig.Options applies it. Every Redis client, the
event bus with its @dbn channel names, and the connection check are built
from those options. A change needs a restart, like redis.url. An error
from Options names the value it could not read, so a number that is not
valid is no longer reported as an invalid URL.

While redis.db is empty, GET /api/v2/admin/settings/effective reports the
number in use under redis.db: the one in the saved URL, or 0 when the URL
has none.

What a save of redis.db stores depends only on the settings that save
leaves in place, on the batch endpoint and the single-key endpoint alike:
nothing when there is no redis.url, nothing when the URL already names the
number, and the number otherwise. A batch that also sets redis.url is
judged against the URL it sets. Earlier saves do not change the outcome,
so an install that once had a number saved and cleared behaves like one
that never had one. A save that does not include redis.db leaves the
stored number alone.

A process started with REDIS_URL takes the whole connection from the
environment, database number included, and does not apply redis.db. There
a save of a number is refused, and the effective value is the number in
REDIS_URL, or 0 when REDIS_URL cannot be parsed. Clearing redis.db is
accepted, so a saved number can be removed while the environment supplies
the connection. The startup code that hands REDIS_URL to the config and to
the settings handlers moves into two functions with tests.

The Redis section of the infrastructure settings page and the Redis row of
the setup wizard get a "Database number" field under the connection URL.
It is read-only when REDIS_URL supplies the connection. Editing the URL
stages the number the field shows along with it, so the number on screen
is the number the save keeps and the connection check tests. A new URL
would otherwise move the install to the number in that URL while the field
still showed the old one. Clearing the field makes the install follow the
URL, and switching Redis off clears the number with the URL. The settings
search finds the field.

docs/admin-settings-api.md describes how the setting is read and written,
and docs/architecture/redis-event-bus.md says which number the channel
names follow.

The silo.yaml import does not read redis.db. The key never existed in
silo.yaml, and the number in an imported redis.url keeps working.

Refs Silo-Server#1863
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1c04f8ad-e482-40c9-8de3-39c51f622ef7
📥 Commits

Reviewing files that changed from the base of the PR and between 387b2db and 4b93d04.

📒 Files selected for processing (25)
  • cmd/silo/log_pipeline_test.go
  • cmd/silo/main.go
  • cmd/silo/redis_bootstrap_test.go
  • docs/admin-settings-api.md
  • docs/architecture/redis-event-bus.md
  • internal/api/handlers/admin.go
  • internal/api/handlers/admin_settings_redis_db_test.go
  • internal/cache/redis.go
  • internal/cache/redis_eventbus_test.go
  • internal/cache/redis_sentinel_test.go
  • internal/config/admin_settings.go
  • internal/config/config.go
  • internal/config/db_loader.go
  • internal/config/redis_db_test.go
  • internal/config/restart_keys_test.go
  • internal/nodeconfig/watcher.go
  • internal/nodeconfig/watcher_test.go
  • web/src/lib/adminSettingsSearch.test.ts
  • web/src/lib/adminSettingsSearch.ts
  • web/src/pages/admin-settings/InfrastructureSettings.test.tsx
  • web/src/pages/admin-settings/InfrastructureSettings.tsx
  • web/src/pages/admin-settings/redisDraft.test.ts
  • web/src/pages/admin-settings/redisDraft.ts
  • web/src/pages/setup-wizard/steps/StorageStep.test.tsx
  • web/src/pages/setup-wizard/steps/StorageStep.tsx
 _______________________________________________
< Finding your faults 10 times faster than Mom. >
 -----------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@silo-kody

silo-kody Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Comment thread internal/cache/redis.go Outdated
if err != nil {
// If the URL cannot be parsed, treat it as a simple address.
opts = &redis.Options{Addr: redisURL}
client = redis.NewClient(unparsedRedisOptions(cfg.URL, err))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug high

Database mismatch in internal/cache/redis.go occurs because the bare-address fallback builds Redis options from cfg.URL alone and discards the new redis.db override: the admin save paths accept a legacy host:port with redis.db set to 5 and display database 5, but the event bus still connects and scopes its channels to database 0. Apply the validated database override to the fallback options before constructing the client.

Prompt for LLM

File internal/cache/redis.go:

Line 176:

Database mismatch in internal/cache/redis.go occurs because the bare-address fallback builds Redis options from cfg.URL alone and discards the new redis.db override: the admin save paths accept a legacy host:port with redis.db set to 5 and display database 5, but the event bus still connects and scopes its channels to database 0. Apply the validated database override to the fallback options before constructing the client.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This was right for 3ec80d1 and is fixed in 4ae8bc5. unparsedRedisOptions now validates redis.db with config.NormalizeRedisDB and sets Options.DB on the bare-address options before building the client (internal/cache/redis.go). The protocol cases in redis_eventbus_test.go ("redis.db on a bare address", "normalized redis.db on a bare address", "redis.db 0 on a bare address") check the selected database and the channel scope. internal/cache tests pass at the current head.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the follow-up. Based on your description, 4ae8bc5e3 addresses the original finding: the bare-address fallback now validates redis.db and applies it to Options.DB before constructing the client.

The protocol tests cover database selection and channel scope for explicit, normalized, and zero overrides. With internal/cache tests passing, I consider this finding addressed based on the reported changes; I haven’t independently inspected the updated commit.

@silo-kody

silo-kody Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the two commits after the #1859 prerequisite (3ec80d1e1, 4ae8bc5e3). One finding, inline below.

I'm also merging main into the branch to clear the conflict left by #1859 landing. It's a merge commit, not a rebase, so nothing gets force-pushed. A summary with the scores follows once the fixes are pushed.

Quick104 and others added 2 commits October 7, 2026 19:49
Silo-Server#1859 landed on main as 387b2db with the same content as the
prerequisite commit 3bf59f5. The conflicts were in files this branch
changes on top of that commit, and keep this branch's side.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
In the setup wizard, emptying the Connection URL staged an empty
redis.db, and typing a URL again left it empty. The save then moved the
install to the database the new URL names instead of the number on
screen. The admin settings page was not affected, because its secret
field turns an emptied input into "keep saved".

stageRedisUrl now stages the number on screen with every URL edit,
including an empty URL. The server already stores no redis.db when the
same write leaves no redis.url, so switching Redis off still removes a
saved number.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@silo-kody

silo-kody Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104

Quick104 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: 4b93d049e. That is the PR's own commits (3ec80d1e1, 4ae8bc5e3) plus the two review commits below.

Addressed

  • Wizard dropped the database number when the URL was emptied and typed again. The save then moved the install to the number in the new URL. Fixed in 4b93d049e with regression tests that fail before the fix (thread).
  • Merge conflict. feat(cache): accept a Redis Sentinel URL in redis.url and REDIS_URL #1859 landed on main as 387b2db4b with the same content as the prerequisite commit. 41bbc83f3 merges main and keeps this branch's side in the conflicted files, so the diff against main now holds only the database-number change. Nothing was force-pushed.
  • Kody's bare-address finding was right for 3ec80d1e1, and 4ae8bc5e3 fixes it. I replied in that thread with the covering tests.

Remaining

  • Needs your call (maintainer): the v1 freeze. The admin settings handlers serve /api/v1 and /api/v2, so redis.db also appears, with its own write rules, on the frozen v1 settings routes. AGENTS.md allows only critical bridge fixes on v1 and names no exception for a new key in an existing settings map. The two options are to accept it as a settings entry or to keep redis.db off the v1 routes. The PR body already flags this.
  • Known tradeoffs. These follow the design in The Redis database number cannot be read back or changed without retyping the whole connection URL #1863 and the PR's Risks section and aren't defects. A process started with REDIS_URL ignores redis.db, so a deployment that mixes REDIS_URL processes with processes on the saved URL can end up on different database numbers. A number the Redis server can't serve stops startup until it's cleared, and REDIS_URL is the way back.
  • CI. Go test fails only on TestUpdateProfile_PINChangeClearsLockout. It fails the same way in main's CI at 387b2db4b and locally on main, so this PR didn't cause it. fix(profiles): keep a profile's PIN proof valid when other profiles change #2020 on main changes that area, so a later merge of main should clear it.
  • Human verification is still pending, per the PR's AI disclosure.

Validated features

I couldn't read the validation board, because the token used for this review lacks read:project. The Validation-labelled issues show no passed case for the admin Redis settings, the setup wizard's storage step, or the Redis connection. The distributed transcode node tasks (#1177, #1178) share Redis, but all their cases are Not run. Validation tasks: none stands, though I couldn't confirm it against the board.

User manual and clients

  • docs: cover Redis database numbers for installs that share one Redis server siloserver.org#82 covers the field. It already says that editing the URL keeps the number shown, which the wizard fix makes true. No change needed.
  • This is server administration in the web UI. Apple and Android need no change.
  • Evidence: going by the PR body, the published captures show the admin settings edit, check, and save path and the field's display. They don't cover the wizard's empty-then-retype path, so the fix doesn't make them stale. I didn't open the evidence page.

Review method

Claude Code (claude-opus-5-5[1m]) ran a multi-angle review with verification, and Codex (gpt-6.1-sol) ran one adversarial round. Codex found the wizard defect. Its fit note on v1 is the open question above.

Verdict

Fit: 7/10 · Readiness: 7/10 — conditional

  • Fit: this closes The Redis database number cannot be read back or changed without retyping the whole connection URL #1863. Admins can see the database number and change it without retyping the credentials in the URL, and installs that share one Redis server depend on that number. It adds a setting and API surface while the project is focused on QA and polish, and the v1 question is still open.
  • Readiness: the approach holds up, the one verified defect is fixed with tests, and the branch merges cleanly. Three things keep it below ready: the required Go test check is red (a baseline failure from main), the v1 decision is open, and human verification is pending.

@Quick104
Quick104 marked this pull request as ready for review October 8, 2026 00:06
@Quick104
Quick104 merged commit 07dd4de into Silo-Server:main Oct 8, 2026
23 of 26 checks passed
@macroscopeapp

macroscopeapp Bot commented Oct 8, 2026

Copy link
Copy Markdown

The setup wizard’s Redis URL empty-and-retype behavior is not covered by the described recording. Please add a short recording of clearing the URL and entering it again while the displayed database number stays unchanged (web/src/pages/setup-wizard/steps/StorageStep.tsx, web/src/pages/admin-settings/redisDraft.ts). The evidence link is provided; the reviewer should be able to verify that flow there.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The Redis database number cannot be read back or changed without retyping the whole connection URL

2 participants