Repository navigation
fix(settings): bind draft Meilisearch checks to saved credentials - #2768
Conversation
Co-Authored-By: Codex (gpt-6.1-sol) <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Major change — #1165 C1: Its 11 Oct issue comment records a human-validated pass on server build The PR must explain why this behavior changes and state that #1165 C1 needs re-validation after merge. Please reconcile the issue’s Not run table with its recorded pass and include the default-port case in the re-test. Suggested fix: No diff; update the validation record and re-test C1 with equivalent default ports after merge. Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
Quick104
left a comment
There was a problem hiding this comment.
Review of 2176d8e. The binding works: on a local build of this head, a draft URL pointing at another host got no key, while the same request on main sent the saved key to the draft host. Two findings below; I'm fixing both in a commit on this branch, so there's no need to change them yourself.
Pre-existing problems this review turned up, kept out of this PR:
- Plugin connection tests fill blank secret fields from the saved entry even when the staged settings point the plugin at another server. The LDAP and OIDC plugins then send the saved bind password or client secret there. Filed as #2796; the fix needs a decision on how a plugin declares which field a secret belongs to.
- The Meilisearch check only calls
/health, which needs no key, so a wrong key still reports success. Filed as #2797, to follow this PR because it changes the same check. - Autoscan connection edits keep the saved key when the URL changes. Already tracked in #2775.
…rects Convert non-ASCII hosts with IDNA before comparing a draft's authority with the saved one, as net/http does when it dials. Unicode lowercasing let a draft such as "meİlisearch" keep the saved key while dialing a punycode twin. Credentialed Meilisearch checks now follow redirects within the same scheme, host and port and report any other redirect with a message asking for the final address, instead of the generic check failure. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
/silo review summaryReviewed head: 6af3547 (the original 2176d8e plus two review-fix commits). Fit: 9/10 · Readiness: 9/10 — ready
Addressed findings
Remaining issuesNone in this change. Two limits are deliberate:
Found during review and kept out of this PR:
Saving a changed address with a blank key still keeps the stored key for these settings, as it does for the AI and embedding settings. This PR protects draft checks only. Requests integrations already require the key again on save; whether admin settings should do the same is a maintainer decision. Validated features
Checks
Review method
|
| if req.URL.Scheme != via[0].URL.Scheme || req.URL.Host != via[0].URL.Host { | ||
| return http.ErrUseLastResponse |
There was a problem hiding this comment.
Incorrect redirect rejection in internal/catalog/search_meilisearch_client.go occurs because the guard compares raw URL.Host strings rather than effective authorities, rejecting a credentialed check from https://search.example.test to https://search.example.test:443/health as another address and prompting administrators to reenter credentials. Compare the canonical scheme, IDNA-normalized hostname, and effective port of both URLs before rejecting the redirect.
Prompt for LLM
File internal/catalog/search_meilisearch_client.go:
Line 222 to 223:
Incorrect redirect rejection in internal/catalog/search_meilisearch_client.go occurs because the guard compares raw URL.Host strings rather than effective authorities, rejecting a credentialed check from https://search.example.test to https://search.example.test:443/health as another address and prompting administrators to reenter credentials. Compare the canonical scheme, IDNA-normalized hostname, and effective port of both URLs before rejecting the redirect.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Confirmed. CheckRedirect compared raw URL.Host strings, so a redirect from https://search.example.test to https://search.example.test:443/... was refused, and a test case for it fails on 5907058. I'm fixing it in a commit on this branch by comparing scheme, host and effective port.
The host comparison stays exact on purpose. net/http drops Authorization on a redirect whose host differs only in letter case, so following one would run the check without the key.
There was a problem hiding this comment.
Fixed in 6af3547. sameCheckAuthority compares scheme, exact host and effective port, so https://host and https://host:443 match and https://host:8443 does not. New table cases cover both. The catalog tests (with -race), the handler tests and changed-lines lint pass.
There was a problem hiding this comment.
Thanks—based on your description, 6af35471d addresses the reported default-port mismatch. The new cases cover both equivalent :443 and distinct :8443 authorities.
Keeping the hostname comparison exact also preserves the intentional safeguard against following a redirect after net/http drops Authorization for a case-only host change. My original recommendation to normalize the hostname was too broad for that redirect behavior.
I haven’t independently inspected the commit or rerun the tests.
There was a problem hiding this comment.
Thanks for confirming. That narrows my original suggestion: normalize effective ports without broadening host matching beyond what preserves Authorization.
Allowing omitted versus explicit default ports fixes the reported false rejection. Keeping the host comparison exact addresses the separate risk you identified: following a case-only host redirect could otherwise turn a credentialed check into an anonymous one.
Regression coverage should distinguish:
- Omitted versus explicit default ports: allowed.
- Different schemes or non-equivalent ports: rejected.
- Case-only host changes: intentionally rejected.
I haven’t changed code or saved anything.
…ects The credentialed check compared raw URL.Host strings, so a redirect from https://host to https://host:443 was refused as another address. It also treated every final 3xx response as a refused redirect, so a 3xx without a Location header got the "enter the address it redirects to" message. Compare scheme, host and effective port, and return ErrMeilisearchCheckRedirected from CheckRedirect itself instead of inferring it from the status code. Hosts still compare exactly, which is stricter than net/http's rule for keeping the Authorization header. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Problem
Meilisearch draft connection checks can reuse a saved API key after an administrator changes the destination. This binds saved-key reuse to the saved authority while preserving direct same-authority path changes and explicitly supplied replacements or clears.
Closes #2766
Related issue: N/A
Validation tasks: changes #1165 C1; additional board coverage unavailable (missing read:project)
Approach
Apply the existing AI and embedding credential-binding rule at the shared settings-check merger. Compare scheme, host and effective port, including equivalent HTTP/HTTPS default ports. Hosts are compared as net/http dials them, after IDNA conversion, so a Unicode look-alike such as
İforicannot keep the saved key while dialing a punycode twin; this also closes that gap for the AI and embedding checks. Bootstrap-managed credentials follow the same rule.Credentialed Meilisearch checks follow redirects only within the same scheme, host and port; any other redirect fails with a message asking for the final address. Anonymous checks retain their redirect behavior. Runtime search/indexing clients, deadlines, settings persistence and encrypted key identities are unchanged. Existing embedding primary and legacy fallback protection is covered by regression tests.
The API documentation records the behavior. Web already sends dirty fields; Apple, Android and jellycompat have no callers of this administrative check boundary. Current manual pages do not describe the affected draft-check behavior, so no client or manual follow-up is needed.
Validation
main, a draft check pointed at another host sent the saved key there; on this branch it sends no key, follows a same-host 308 with the key, and reports a redirect to another port with the specific message.Locationfail on 5907058 and pass on 6af3547. They drive the real net/http redirect logic through an in-memory transport; no live server ran for that commit.ci / Go testfails only inTestAdminDefaultChangeReachesEveryViewer, which fails onmaintoo ([bug] Administrator default changes no longer reach any events socket #2748, fix in fix(events): deliver administrator default changes to every viewer #2754).Evidence
Live before/after check results on
main, the original head and the review fixes are published privately. This change has no layout or rendered-data changes; the only new admin-visible text is the redirect message.Evidence: https://evidence.siloserver.org/r/silo-server/issue-2766/
Risks
A credentialed check whose address redirects to another scheme, host or port fails and asks for the final address. Checks without a key continue to support redirects.
Follow-ups found in review, outside this change: #2796 (plugin connection tests reuse saved secrets after a staged destination change), #2797 (the Meilisearch check passes without testing the key; follows this PR), #2775 (autoscan edits keep the saved key across addresses).
Checklist
AI Disclosure
/siloreview fixes.delegate_task; Claude Code tools.gpt-6.1-sol(implementation, high-effort source reviewers and sweep);claude-opus-5-5(high-effort approach and background review)./siloreview (Claude Code,claude-opus-5-5, with a read-onlygpt-6.1-solcross-provider round through the Codex CLI) found the IDNA host comparison gap and the unexplained redirect failure, and fixed both in 5907058. A second/siloreview round (same models) confirmed a Kody finding that the redirect guard refused a redirect that only added the default port, found that any unfollowed 3xx was reported as a refused redirect, and fixed both in 6af3547. Validation-board coverage remains unverified.Note
Bind draft Meilisearch connection checks to saved credentials and restrict redirects
ErrMeilisearchCheckRedirectedand the handler answers with a generic safe message; keyless probes keep normal redirect behavior.AdminHandler.effectiveSettingsForConnectionChecknow clears the stored Meilisearch API key when a draft URL points to a different authority; check any callers that relied on the key carrying over. Redirect sentinel handling is new incheckMeilisearchConnection.Macroscope summarized 6af3547.