mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6936] [MERGED] fix(ldap): keep trusted baseline after rejected fetch #6531
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#6531
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/6936
Author: @muditagrawal2007
Created: 10/25/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @MHSanaei
Base:
main← Head:fix/ldap-auto-delete-safe-baseline📝 Commits (2)
ac7663afix(ldap): keep trusted baseline after rejected fetch169f465docs(ldap): explain the empty-fetch guard📊 Changes
3 files changed (+277 additions, -12 deletions)
View changed files
➕
internal/web/job/ldap_auto_delete_baseline_test.go(+263 -0)📝
internal/web/job/ldap_auto_delete_guard_test.go(+1 -1)📝
internal/web/job/ldap_sync_job.go(+13 -11)📄 Description
Fixes #6935
Summary
The LDAP auto-delete retention guard currently protects only one cron tick. A rejected partial directory result is still stored as the next trusted population, so the following tick can detach clients that are still present in LDAP.
This PR keeps the baseline unchanged whenever the safety guard rejects a fetch.
Root cause
The guard and the baseline update were separated:
lastFlagCountwas updated even whenautoDeleteSafeForFetchreturnedfalse.The fix
lastFlagCounttolastTrustedFlagCountso the invariant is explicit.Policy note
The retention guard already deliberately refuses an implausible directory collapse. This PR makes that policy consistent instead of weakening it on the next tick. A genuine offboarding of more than half the directory therefore remains blocked by design; an operator can accept a legitimate large offboarding by temporarily disabling auto-delete for one successful sync (which advances the baseline), then re-enabling it. No new override switch is introduced because it would weaken the existing safety boundary.
Regression coverage
internal/web/job/ldap_auto_delete_baseline_test.goadds two end-to-end job tests:TestLdapAutoDeleteKeepsBaselineAfterRefusedFetchTestLdapAutoDeleteKeepsBaselineAfterEmptyFetchThe tests use:
LdapSyncJob.Runpath;They assert the exact set of clients still attached to the inbound after each tick.
Red before the fix
Green after the fix
Verification
All commands pass.
make verifyincludes generated-file freshness, Go and frontend lint, formatting, typecheck, all Go tests, all 1,978 frontend tests, the production build, and the Storybook build.No database migration, API, or frontend change is required.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
[PR #6936] fix(ldap): keep trusted baseline after rejected fetchto [PR #6936] [MERGED] fix(ldap): keep trusted baseline after rejected fetch