Skip to content

feat(config): set Meilisearch and the Audiobookshelf port from the environment - #3117

Merged
Quick104 merged 2 commits into
mainfrom
silo/search-provider-abs-port-env-vars
Oct 27, 2026
Merged

Quick104 merged 2 commits into
mainfrom
silo/search-provider-abs-port-env-vars

Conversation

@Quick104

@Quick104 Quick104 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #3105
Related issue: N/A
Validation tasks: none (no passed case in the Validation issues reaches this change; the board itself was not readable with the author's token)

Packaged deployments (Compose stacks, app catalogs such as TrueNAS, all-in-one images)
start Meilisearch next to Silo but cannot connect the two at deploy time. The provider,
URL and key exist only as admin settings, so every install needs a trip to the admin UI
after first start, or a script that writes server_settings rows before Silo runs. Until
then Silo quietly stays on Postgres search. The Audiobookshelf listener is fixed at
13378, so a deployment on the host network, or one where 13378 is taken, cannot move it.

This adds SILO_SEARCH_PROVIDER, SILO_MEILISEARCH_URL and SILO_MEILISEARCH_API_KEY,
which behave like SILO_TRUSTED_PROXIES, and ABS_PORT, which behaves like JF_PORT.

Approach

  • When a search variable is set (blank counts as unset), an API server normalizes it the
    way an admin save does: the provider must be postgres or meilisearch, and the URL
    needs an http or https scheme and a host. The values that differ from the stored ones
    are written in one batch through the encrypting settings store before the search
    provider is built, so the key rests encrypted under its existing setting name. An
    invalid value stops startup with a message that names the variable.
  • The keys are reported in managed_by_env, so saves of them are refused, and the admin
    Search page disables those fields and names the variable. The page now waits for the
    protected-credential status before it renders, as the General page does, so it never
    takes an edit the server would refuse. If that status fails to load, the search engine,
    URL and key fields stay disabled with a note to reload.
  • An unset variable leaves the stored value alone and editable again. The variables are
    read per process, like SILO_TRUSTED_PROXIES and REDIS_URL, so every API server
    sharing a database needs the same values; .env.example and
    docs/admin-settings-api.md say so.
  • ABS_PORT (default 13378) moves the Audiobookshelf listener at startup and after config
    reloads. A listener disabled in settings stays disabled.
  • .env already uses ABS_PORT for the host side of the Compose port mapping, and the
    silo service loads .env, so both Compose files now pin ABS_PORT: "13378" inside the
    container next to PORT and JF_PORT. docker-compose.dev.yml did not pin JF_PORT
    either, so it gets that pin too.

The /api/v2 shapes do not change; managed_by_env can now list three more keys. Apple,
Android and Jellyfin clients call nothing that changed.

Validation

  • Live, on a sandbox with Meilisearch beside it and all four variables set. On main,
    Silo ignored them: Postgres search, nothing stored, Audiobookshelf on 13378. On this
    branch, search runs on Meilisearch and indexed the library with the key from the
    environment; the stored rows hold the normalized values with the key encrypted;
    managed_by_env lists the three keys; a settings write of the provider returns 422; the
    connection check passes; a restart rewrites nothing; Audiobookshelf answers on 13379
    only.
  • Edge cases, live: an unset variable keeps its stored value and unlocks its field; an
    invalid provider stops startup with a clear message; a disabled Audiobookshelf listener
    stays off; an unreadable storage-transition row does not block the startup write.
  • docker compose config with host-side ABS_PORT and JF_PORT in .env keeps the
    container ports pinned in both Compose files.
  • Go: build, vet, gofmt, make lint-changed (0 issues), and the tests of the touched
    packages pass. In make test-go on the macOS test host, failures in jellycompat,
    metadata/nfo, scanner and subtitles/subsync fail on main there too, and
    TestCopyRemuxSubtitleRenditionRealFFmpeg (real ffmpeg, untouched package) timed out.
  • Web: lint (no new warnings), format, build, bundle budget and make test-web pass.
  • The new Go tests call code this change adds, so they cannot run on main; the live
    before and after is the proof, and the tests guard the edge cases. The page test for a
    failed credential-status load, which a sandbox cannot easily produce, fails on the
    commit before that fix and passes now.

Evidence

Admin Search page on desktop, before and after, plus the page with one variable unset and
at phone width, from sandbox builds of main and of this branch.

Evidence: https://evidence.siloserver.org/r/silo-server/issue-3105/

Risks

  • Older Compose files. An install that sets ABS_PORT in .env to change the host
    port and keeps a docker-compose.yml without the new pin will, after pulling this
    image, run the Audiobookshelf listener on that port inside the container, where the
    port mapping does not reach it. Updating docker-compose.yml, or adding
    ABS_PORT: "13378" to the silo service's environment, fixes it. docker run --env-file
    setups are affected the same way. The user-manual update carries an upgrade note.
  • Mixed API servers. API servers that share a database but get different search
    variables disagree about search until their variables match, and each start writes its
    own values. This is the same model as SILO_TRUSTED_PROXIES.
  • Invalid values stop the server at startup, on purpose, as an invalid
    SILO_TRUSTED_PROXIES does.
  • Audiobookshelf compatibility is beta; this only makes its port configurable.

Follow-ups:

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code, run from T3 Code
  • Tool(s): Claude Code; T3 Code delegate_task for the Codex reviews
  • Model(s): claude-opus-5-5 (implementation, review subagents), claude-sonnet-5-5 (cleanup and validation review subagents), gpt-6.1-sol (plan review, background review)
  • Involvement: Fully AI-generated at the maintainer's direction; human verification pending
  • Adversarial review:
    • Plan: gpt-6.1-sol attacked the plan before implementation. Adopted: write the
      connection settings in one batch, and hold the Search page until it knows which fields
      the environment sets. Answered by documenting it: API servers sharing a database need
      the same variables, as with SILO_TRUSTED_PROXIES.
    • Diff: claude-opus-5-5 and claude-sonnet-5-5 subagents reviewed it. They found that the
      first version of the startup write read and decrypted every setting under the global
      settings lock, so an unreadable storage-transition row would have stopped startup. It
      now writes one batch against the settings Silo already reads at startup. They also
      fixed a docs claim about the stored key and trimmed duplicate tests. The Compose
      upgrade case is listed under Risks.
    • Background review: gpt-6.1-sol reviewed 2bf7434 adversarially and found nothing.
      The later commit 765f5dc addresses a CodeRabbit finding: the Search page now holds
      the connection fields when credential status fails to load.

🤖 Generated with Claude Code

Note

Add ABS_PORT and Meilisearch environment variables to Silo startup config

  • On primary nodes, startup reads search provider, Meilisearch URL, and API key from the environment, validates and normalizes them, and persists only changed values via StoreSearchSettings in search_env.go. Invalid values exit the server with an error naming the variable.
  • config.LoadBootstrap reads ABS_PORT (default :13378), and the new WithBootstrapListen helper moves an enabled Audiobookshelf listener to that address at startup and on every config reload in watcher.go.
  • The admin Search Settings page locks fields that are environment-managed, shows the matching variable name, and disables the provider and connection fields with a warning if managed-status cannot be loaded (SearchSettings.tsx).
  • Risk: environment values replace admin-UI search settings and must match across API servers; a nonempty ABS_PORT overrides a configured enabled listener address on every reload. SetMany added to the encrypted settings test store in encrypted_settings_repo_test.go.

Macroscope summarized 765f5dc.

…vironment

SILO_SEARCH_PROVIDER, SILO_MEILISEARCH_URL and SILO_MEILISEARCH_API_KEY,
when set, win over the stored search settings on every start of an API
server. Each value is normalized the way an admin save is, the ones that
differ are stored in one batch through the encrypting settings store, and
the keys are reported as managed by the environment, so the admin Search
page locks them and saves of them are refused.

ABS_PORT moves the Audiobookshelf listener the way JF_PORT moves the
Jellyfin one, defaulting to 13378. The Compose files pin it inside the
container, since .env uses ABS_PORT for the host side of the mapping.

Closes #3105

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Oct 27, 2026
@silo-kody

silo-kody Bot commented Oct 27, 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 ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T00:37:33.204131Z 765f5dc New commits
🔒 Security Review ✅ Completed 2026-10-27T00:39:18.729771Z 765f5dc New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The change adds environment-based configuration for Meilisearch settings and the Audiobookshelf listener port. It persists search values at startup, identifies environment-managed search controls in the admin UI, and applies the listener port override through bootstrap configuration.

Changes: Environment-Driven Search Settings

Layer / File(s) Summary
Parse and store search settings
internal/catalog/search_env.go, internal/catalog/search_env_test.go, internal/catalog/encrypted_settings_repo_test.go, .env.example
Search environment values are trimmed and normalized. Changed values are stored in a batch. Tests cover parsing, encryption, and unchanged values.
Load search settings at startup
cmd/silo/main.go, docs/admin-settings-api.md
Primary nodes load and persist environment-provided search values, then overlay them in memory. The documentation describes environment-managed settings and their storage behavior.
Show environment-managed search fields
web/src/pages/admin-settings/SearchSettings.tsx
The admin form identifies the managing environment variable and disables controls for settings managed by the environment.

Audiobookshelf Listener Port

Layer / File(s) Summary
Read and apply the bootstrap port
internal/config/bootstrap.go, internal/config/config.go, internal/config/db_loader.go, internal/config/bootstrap_test.go, docker-compose.yml, docker-compose.dev.yml
Bootstrap configuration reads ABS_PORT, defaults to 13378, and applies the address to an enabled listener. Compose files set the container port.
Pass the port through runtime configuration
internal/nodeconfig/watcher.go, cmd/silo/main.go
The bootstrap override is applied during configuration setup and passed to the API config watcher, which applies it to Audiobookshelf compatibility settings.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant SiloStartup
  participant SearchSettingsFromEnv
  participant EncryptedSettingsRepo
  participant InMemorySettings
  SiloStartup->>SearchSettingsFromEnv: Read and normalize environment values
  SiloStartup->>EncryptedSettingsRepo: Store changed search settings
  SiloStartup->>InMemorySettings: Overlay environment-provided settings
Loading
sequenceDiagram
  participant LoadBootstrap
  participant APIConfigWatcher
  participant AudiobookshelfCompatConfig
  LoadBootstrap->>APIConfigWatcher: Pass ABSListen bootstrap override
  APIConfigWatcher->>AudiobookshelfCompatConfig: Apply WithBootstrapListen
Loading

Possibly related PRs

  • Silo-Server/silo-server#2931: Changes Meilisearch connection checks to use the configured API key, which this change can provide through the environment.

Suggested labels: enhancement, go, javascript, needs-review, impact: usability, evidence-required, size/L

Suggested reviewers: rhainland

Merge Risk: Low · up to 2bf74

If the status request fails, administrators can attempt changes to environment-managed search settings without seeing why the save failed. The server still protects those settings; this is a bounded UI issue to fix or accept before merging.

Security architecture risk: Low · up to 2bf74

Encrypted credential storage, validation, server-side write restrictions, and existing listener controls are preserved. The main remaining risk is configuration drift during deployment: API servers must use matching search settings, and removing an environment variable does not undo its persisted value.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A deployment actor controlling these variables can select the search destination and credentials used by that API process. Persistence extends the configuration effect to other processes using the same settings database, rather than confining it to one user or administrator session. Actual replica count and environment isolation were not established.

Trust Boundaries and Controls

  • observed — The new search source is the process environment, not request input, and managed-setting writes remain restricted server-side. The configurable Audiobookshelf listener retains its existing client-IP and ingress-token middleware, with bearer authentication on protected browse routes; changing its port does not remove those controls.

Resilience and Maintainability Implications

  • inferred — The settings transaction contains partial-write failures: interruption before commit leaves no partial batch, while interruption after commit leaves encrypted values available on restart. This recovery boundary does not coordinate external search-service credentials or restore prior settings when environment ownership is removed.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 10 files. (4 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main changes: environment-based Meilisearch configuration and Audiobookshelf port configuration.
Linked Issues check Passed Issue #3105 has two coding objectives. For search configuration, SearchSettingsFromEnv reads the three requested variables, ignores blank values, normalizes values with admin-setting rules, and repo…
Out of Scope Changes check Passed The changes remain within issue #3105. The admin UI changes enforce environment ownership of the requested search settings. The encrypted batch-store changes, tests, documentation, .env.example, and…
Description check Passed The description is specific and on-topic. It names the problem (Meilisearch and ABS_PORT cannot be set at deploy time), the new variables SILO_SEARCH_PROVIDER, SILO_MEILISEARCH_URL, SILO_MEILISEARCH_A…
Full details: Linked Issues check

Explanation

Issue #3105 has two coding objectives. For search configuration, SearchSettingsFromEnv reads the three requested variables, ignores blank values, normalizes values with admin-setting rules, and reports the variable on validation errors. StoreSearchSettings writes changed values in one batch through EncryptedSettingsRepo, so the API key remains encrypted. The startup path applies these values before the search provider is built, and the values are reapplied per API-server start. For the listener objective, LoadBootstrap reads ABS_PORT with a 13378 default, and the watcher reapplies the address after configuration reloads without enabling a disabled listener. The admin UI, managed-setting API behavior, Compose configuration, documentation, and added tests support these requirements.

Full details: Out of Scope Changes check

Explanation

The changes remain within issue #3105. The admin UI changes enforce environment ownership of the requested search settings. The encrypted batch-store changes, tests, documentation, .env.example, and Compose pins support deploy-time configuration and its documented behavior. The ABS_PORT bootstrap and reload changes implement the requested listener configuration. No unrelated product behavior is demonstrated.

Full details: Description check

Explanation

The description is specific and on-topic. It names the problem (Meilisearch and ABS_PORT cannot be set at deploy time), the new variables SILO_SEARCH_PROVIDER, SILO_MEILISEARCH_URL, SILO_MEILISEARCH_API_KEY and ABS_PORT, the approach (normalization, encrypted storage, managed_by_env locking, Compose pins), validation steps, and risks. It matches the changeset summaries for search_env.go, bootstrap.go, config.go, watcher.go, main.go, the Compose files, the docs, and SearchSettings.tsx.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 10 files. (4 skipped: 4 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@silo-triage silo-triage Bot added enhancement New feature or request go Pull requests that update go code javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish labels Oct 27, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 27, 2026

Copy link
Copy Markdown

The evidence link covers the admin Search page (desktop before/after and the phone-width state with a variable unset), but it does not show these other visible effects:

  • internal/catalog/search_env.go: selecting Meilisearch can change search results and their order. Add before-and-after response excerpts for the same query and library, identifying the builds.
  • internal/config/bootstrap.go: ABS_PORT changes the port Audiobookshelf-compatible clients use to connect. Add before-and-after evidence showing the same ABS-compatible endpoint on the default and configured ports.

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

Posted via Macroscope — Visible change evidence

@coderabbitai coderabbitai Bot added evidence-required Needs before-and-after evidence before the Evidence check passes impact: usability Core flow broken or severely blocked needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. labels Oct 27, 2026

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8b54d70f-9fdd-43eb-9ab4-438a40287172
Commits

Reviewing files that changed from the base of the PR and between 8b84639 and 2bf7434.

Files selected for processing: 14
  • .env.example
  • cmd/silo/main.go
  • docker-compose.dev.yml
  • docker-compose.yml
  • docs/admin-settings-api.md
  • internal/catalog/encrypted_settings_repo_test.go
  • internal/catalog/search_env.go
  • internal/catalog/search_env_test.go
  • internal/config/bootstrap.go
  • internal/config/bootstrap_test.go
  • internal/config/config.go
  • internal/config/db_loader.go
  • internal/nodeconfig/watcher.go
  • web/src/pages/admin-settings/SearchSettings.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Without the protected-credential status the Search page cannot tell which
fields the environment sets, so a save of one could be refused. Disable the
search engine, URL and API key fields and say to reload, as the General page
does for Redis.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 27, 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

Copy link
Copy Markdown
Contributor Author

On the two gaps the evidence check named:

  • Search results: this change doesn't touch how either engine ranks or returns results. It only lets the environment choose the provider an admin could already pick on the Search page. The evidence shows which engine answers before and after (configured_provider and active_provider from /api/v2/admin/catalog/search/status) and that the index synced with the key from the environment.
  • ABS_PORT: the evidence page's "Server behavior" section has the before and after for the same endpoint. On main, /ping answered on 13378 with ABS_PORT=13379 set. On this branch it answers on 13379, nothing listens on 13378, and the startup log line changes from addr=:13378 to addr=:13379.

@macroscopeapp

macroscopeapp Bot commented Oct 27, 2026

Copy link
Copy Markdown

The protected-credential-status failure state in web/src/pages/admin-settings/SearchSettings.tsx is newly visible: it disables the search controls and displays a reload message. The linked evidence description covers normal desktop/mobile states, not this failure state; add a capture of the Search page with protected credential status unavailable, from the PR build. Suggested fix: add that failure-state capture; no diff.

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

enhancement New feature or request evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code impact: usability Core flow broken or severely blocked javascript Pull requests that update javascript code needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure Meilisearch and the Audiobookshelf listener port through environment variables

1 participant