mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 13:00:55 +00:00
* 🪜 fix: Base-First Config Precedence, Profile Lifecycle and Role Renames That Keep Their Profile Config documents merge in one total order (`compareConfigPrecedence`): Base (`role` / `__base__`) first whatever its priority, then ascending priority, then role < group < user, then document `_id`. The merge, `getApplicableConfigs` and `listAllConfigs` all use it, so a tie no longer goes to the newest document whatever its type, and Base no longer outranks a profile through its priority. A profile that writes fields of a librechat.yaml MCP server therefore undoes a Base hide of that server for its principals. A write that creates a document without a priority gives it its principal type's default (role 10, group 20, user 100, Base 0), and a write that omits the priority keeps the stored one, so a broad PUT no longer resets a profile to 10. Langfuse writes no longer pass a priority. Profile writes (PUT, PATCH `/fields`, POST `/changes`) validate on librechat.yaml with the active Base document resolved over it (`resolveRawConfig`, the fold the merge itself runs), so a role write that is valid where it lands is accepted and one the merge would strip is refused. Base still validates on librechat.yaml alone, an inactive Base is ignored, and `/changes` still judges what librechat.yaml itself defines on the raw YAML. `PATCH /api/admin/config/:principalType/:principalId/priority { priority, expectedRevision? }` sets only the priority, for broad `manage:configs`, keeping overrides, tombstones and `isActive`; it is audited as `operation: 'priority'`. A write that would create a principal's first document (PUT, PATCH `/fields`, POST `/fields/tombstone`, POST `/changes` including a dry run or a priority-only batch) answers 404 `PRINCIPAL_NOT_FOUND` unless the role (exact name), group or user (lowercase ObjectId) exists in the caller's tenant partition, or at platform level outside a tenant (`principalExists`). Each route checks inside its compare-and-swap write, against the document the write replaces; the tombstone route now plans its write like the others, so `AdminConfigDeps` no longer takes `tombstoneConfigField`. A PUT with `expectedRevision: 'absent'` creates the profile even when it carries no overrides. Renaming a role moves its config profile, system grants and ACL entries to the new name in the caller's tenant partition. The profile moves through the store contract (`movePrincipal`: a create-only copy, then removal at the copied revision). A profile already at the new name answers 409 `ROLE_CONFIG_CONFLICT`, and any failed step rolls back the users, the role document and every move (500 `ROLE_RENAME_FAILED`). Profiles, grants and ACL entries that renames made before this change left at an old name are neither moved nor removed, and a role created under that name still picks them up. The Base principal id is a reserved role name (400 `ROLE_NAME_RESERVED`), and a legacy role by that name never moves or deletes Base. The admin config meta reports `deterministicPrecedence`, `priorityRoute`, `principalCheck` and `roleRenameMovesProfile`. * 🧪 test: Give the E2E Reload Sentinel a Role of Its Own Admin config writes now answer 404 PRINCIPAL_NOT_FOUND for a principal that does not exist, so the content-filter helpers' reload sentinel (a made-up user id) could no longer write and every spec that reloads librechat.yaml failed. The sentinel is now a role the helper creates once (409 when it already exists) and deletes after its profile in cleanup; no user is a member, so its empty profile changes no one's config. * 🛟 fix: Keep a Moved Profile Whose Removal Cannot Be Confirmed, Validate on the Caller's Base and Restore Rolled-Back Descriptions - `movePrincipal` no longer treats a failed read-back of the source, after its removal failed, as the source still being there. It keeps the copy, which may be the only one left, and rethrows the removal's failure instead of deleting the copy. - Profile writes read the Base validation floor from the caller's tenant partition, so a caller without a tenant validates on the platform-level Base and never on a tenant's. - A role rename that rolls back gives a role stored without a description the schema default back, instead of a `$set` of `undefined` that kept the new description. * 🧭 fix: Scope Profile Priority Changes to the Caller's Tenant Partition `setConfigPriority`, behind PATCH `/api/admin/config/:principalType/:principalId/priority`, read and wrote through the unpartitioned config store. A platform-level admin without a tenant runs in the default non-strict context, where the tenant-isolation plugin adds no predicate, so the route could reorder a tenant's profile for the same principal, and answer with it, when no platform-level profile existed. It now runs on the partitioned operations that the role rename and the partitioned `findConfigByPrincipal` use. The read is limited to the caller's partition: that tenant's document, or without a tenant only a platform-level one (no tenant, `null` or `''`). The write is pinned to the `_id` of the document that read returned. A tenantless caller therefore gets 404 `CONFIG_NOT_FOUND` for a profile only a tenant holds. An `expectedRevision` naming such a profile gets a revision conflict and changes nothing. Tests: `config.spec.ts` (data-schemas) adds "setConfigPriority in the caller tenant partition". It covers the platform profile changing alone, a profile that only a tenant holds being neither changed nor returned, and only the active tenant's profile changing inside a tenant. The tenant helpers are now shared with the rename suite. `config.precedence.integration.spec.ts` adds the same check through the handler. With the old wiring, a tenantless PATCH of a profile only tenant-a holds answers 200 and moves tenant-a's profile to 40. With the fix it answers 404 and tenant-a keeps 10. * 🧷 fix: Roll Back Only What a Rename Changed and Validate Profile Writes on the Base They Land Over - Grant moves report what they changed (re-keyed grants, and superseded grants whose removal was confirmed); the undo re-keys only grants still at the new name and re-creates a superseded grant only while the new name still holds the grant that superseded it, so a grant revoked during a rename is never resurrected. - The Mongoose binding settles a create whose acknowledgement was lost by the `_id` it chose (found at version 1: committed, returned), as the store contract now requires; a profile move whose copy committed finishes instead of leaving an orphan copy. The memory engine and the conformance suite cover it, plus a copy that cannot be withdrawn being logged. - A rename rollback moves back only the profile it moved (by identity, edits included), puts back only members still on the new name, and reverts the description only while it is still the one the rename set. - PUT, PATCH /fields and POST /changes read Base beside the profile on every attempt and read it again once the write commits; a write that Base changed under is judged on that Base and withdrawn (only at the revision it wrote) when it fails there. - The priority route rereads a lost race's current revision in the caller's tenant partition. |
||
|---|---|---|
| .. | ||
| api | ||
| chat | ||
| client | ||
| data-provider | ||
| data-schemas | ||