mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6964] [MERGED] fix(scripts): preserve custom webBasePath during updates #6546
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6546
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6964
Author: @HamedSanaei
Created: 10/26/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @MHSanaei
Base:
main← Head:fix/preserve-custom-web-base-path📝 Commits (1)
a99be10fix(scripts): preserve custom webBasePath during updates📊 Changes
3 files changed (+315 additions, -10 deletions)
View changed files
📝
install.sh(+19 -5)➕
scripts_base_path_test.go(+277 -0)📝
update.sh(+19 -5)📄 Description
Summary
Preserve configured panel paths during updates and reinstallations, including
/a/and/ab/. Only initialize a missing/default root path, and skip configuration changes if the CLI settings read fails or is malformed.Why
Fixes #6961.
Problem: Valid short custom panel paths are silently replaced during updates or reinstallations.
Root cause: Both scripts strip the leading slash and use a minimum-length check to decide whether
webBasePathis uninitialized. The CLI and frontend accept these short custom paths. The existing pipelines also discard CLI failures, which can turn an unsuccessful settings read into an apparent empty path.Solution: Validate one settings snapshot before changing configuration, distinguish an explicitly empty value from a missing/malformed record, and replace the length check with an empty/root check. Retain the installer's separate default-credential initialization branch, so a short custom path does not prevent insecure default credentials from being replaced. Custom credentials, configured certificates, database selection, and existing service workflows remain unchanged. Configuration-read failures do not prevent the surrounding installer from completing service setup or the updater from completing its existing post-configuration steps. Path handling requests an update restart only when a new path is initialized.
Historical context: #5179 reported the same overwrite alongside a login desynchronization. Commit
f88f53cd7b8a6fc0c5eb6a12170f7630f395ee8eadded the restart after regeneration, addressing the desynchronization symptom while leaving the path-length condition in place. This PR addresses that remaining overwrite condition.Type of change
Areas affected
How was this tested?
The new Go regression tests execute the actual Bash configuration functions and random generator extracted from each script. The CLI, network requests, service restarts, SSL setup, and installation-result writer use temporary fixtures; the installers themselves are never sourced or executed against the host. These tests run automatically in the existing Go CI jobs; native Windows skips them with instructions to use WSL.
Red → green: the original path overwrite and failed-read mutations were reproduced before implementation (24 failures in the initial 44-case suite). The final 46-case suite also checks that read failures leave the existing service-setup flow intact. All cases pass, covering:
/and missing stored paths initialize once with an 18-character random path. The CLI fixture normalizes a missing stored value to/, matching the realGetBasePathbehavior./a/,/ab/,/abc/,/mypanel/, and paths containing spaces remain unchanged.Commands run under Linux/amd64 in WSL:
bash -n update.shbash -n install.shgo test -run '^TestScriptConfig' -count=1 -v .go test -race -run '^TestScriptConfig' -count=1 .shellcheck --severity=error install.sh update.sh(ShellCheck 0.9.0; matches repository CI policy)GOFLAGS=-p=2 make verifyAll 11 CI checks passed on final commit
a99be10d499b09278075bd0f2cbf2f3e8fe8163c, including shell lint, Go tests/lint, race, frontend, code generation, parser fuzzing, vulnerability checks, PostgreSQL checks, and node end-to-end tests.Breaking changes
None for valid existing configurations. A failed or malformed settings read now skips configuration changes and logs an error instead of guessing that the path is unset. Existing service setup continues. Missing/default paths retain secure initialization. No API, database schema, frontend validation, or TLS policy changes. No production installation or deployment was performed.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass. (No frontend changes.)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
[PR #6964] fix(scripts): preserve custom webBasePath during updatesto [PR #6964] [MERGED] fix(scripts): preserve custom webBasePath during updates