🛡️ fix: Preserve CREATE/SHARE/SHARE_PUBLIC Permissions with Boolean Config#11647
Merged
danny-avila merged 6 commits intodevfrom Feb 5, 2026
Merged
🛡️ fix: Preserve CREATE/SHARE/SHARE_PUBLIC Permissions with Boolean Config#11647danny-avila merged 6 commits intodevfrom
danny-avila merged 6 commits intodevfrom
Conversation
… function - Removed explicit SHARE and SHARE_PUBLIC permissions for PROMPTS when prompts are true, simplifying the permission logic. - Adjusted the permissions structure to conditionally include SHARE and SHARE_PUBLIC based on the type of interface configuration, enhancing maintainability and clarity in permission management. - Updated related tests to reflect the changes in permission handling for consistency and accuracy.
…sions - Introduced a new `create` property in the permission configuration object to improve flexibility in permission management. - Updated helper functions to accommodate the new `create` property, ensuring backward compatibility with existing boolean configurations. - Adjusted default values for prompts and agents to include the new `create` property, enhancing the overall permission structure.
- Introduced tests to ensure existing SHARE and SHARE_PUBLIC values are preserved when using boolean configuration for agents. - Added validation to confirm that SHARE and SHARE_PUBLIC are included in the update payload when using object configuration, enhancing the accuracy of permission management. - These tests address potential regressions and improve the robustness of the permission handling logic in the updateInterfacePermissions function.
- Moved the creation of the domainSeparatorRegex to the beginning of the loadToolDefinitionsWrapper function for improved clarity and performance. - Removed redundant regex initialization within the function's loop, enhancing code efficiency and maintainability.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes permission persistence issues by ensuring that SHARE and SHARE_PUBLIC permissions set via the admin panel are preserved when using boolean configuration for prompts and agents. It also adds the create permission field to the schema for better granular control.
Changes:
- Added
createpermission to prompts and agents configuration schemas and defaults - Modified permission update logic to conditionally include SHARE/SHARE_PUBLIC based on config type and existing permissions
- Updated tests to reflect new behavior and added regression tests for permission preservation
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/data-provider/src/config.ts | Added create field to prompts and agents schemas and set defaults to true |
| packages/api/src/app/permissions.ts | Refactored permission update logic to conditionally spread SHARE/SHARE_PUBLIC permissions based on config type and existence of existing permissions, and added support for configurable CREATE permissions |
| packages/api/src/app/permissions.spec.ts | Updated test expectations to reflect new behavior where SHARE/SHARE_PUBLIC are omitted for boolean configs with existing permissions, and added two new tests for regression coverage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ndling - Added a new test to ensure that SHARE and SHARE_PUBLIC permissions are preserved when using object configuration without explicit share/public keys. - Updated existing tests to validate the inclusion of SHARE and SHARE_PUBLIC in the update payload when using object configuration, improving the robustness of permission management. - Adjusted the updateInterfacePermissions function to conditionally include SHARE and SHARE_PUBLIC based on the presence of share/public keys in the configuration, enhancing clarity and maintainability.
- Simplified the logic for including CREATE, SHARE, and SHARE_PUBLIC permissions in the update payload based on the presence of corresponding keys in the configuration object. - Adjusted tests to reflect the changes, ensuring that only the USE permission is updated when existing permissions are present, preserving the database values for CREATE, SHARE, and SHARE_PUBLIC. - Enhanced clarity in comments to better explain the permission management logic.
PreciousOritsedere
pushed a commit
to solid/LibreChat
that referenced
this pull request
Feb 10, 2026
…onfig (danny-avila#11647) * 🔧 refactor: Update permissions handling in updateInterfacePermissions function - Removed explicit SHARE and SHARE_PUBLIC permissions for PROMPTS when prompts are true, simplifying the permission logic. - Adjusted the permissions structure to conditionally include SHARE and SHARE_PUBLIC based on the type of interface configuration, enhancing maintainability and clarity in permission management. - Updated related tests to reflect the changes in permission handling for consistency and accuracy. * 🔧 refactor: Enhance permission configuration in updateInterfacePermissions - Introduced a new `create` property in the permission configuration object to improve flexibility in permission management. - Updated helper functions to accommodate the new `create` property, ensuring backward compatibility with existing boolean configurations. - Adjusted default values for prompts and agents to include the new `create` property, enhancing the overall permission structure. * 🧪 test: Add regression tests for SHARE/SHARE_PUBLIC permission handling - Introduced tests to ensure existing SHARE and SHARE_PUBLIC values are preserved when using boolean configuration for agents. - Added validation to confirm that SHARE and SHARE_PUBLIC are included in the update payload when using object configuration, enhancing the accuracy of permission management. - These tests address potential regressions and improve the robustness of the permission handling logic in the updateInterfacePermissions function. * fix: accessing undefined regex - Moved the creation of the domainSeparatorRegex to the beginning of the loadToolDefinitionsWrapper function for improved clarity and performance. - Removed redundant regex initialization within the function's loop, enhancing code efficiency and maintainability. * 🧪 test: Enhance regression tests for SHARE/SHARE_PUBLIC permission handling - Added a new test to ensure that SHARE and SHARE_PUBLIC permissions are preserved when using object configuration without explicit share/public keys. - Updated existing tests to validate the inclusion of SHARE and SHARE_PUBLIC in the update payload when using object configuration, improving the robustness of permission management. - Adjusted the updateInterfacePermissions function to conditionally include SHARE and SHARE_PUBLIC based on the presence of share/public keys in the configuration, enhancing clarity and maintainability. * 🔧 refactor: Update permission handling in updateInterfacePermissions - Simplified the logic for including CREATE, SHARE, and SHARE_PUBLIC permissions in the update payload based on the presence of corresponding keys in the configuration object. - Adjusted tests to reflect the changes, ensuring that only the USE permission is updated when existing permissions are present, preserving the database values for CREATE, SHARE, and SHARE_PUBLIC. - Enhanced clarity in comments to better explain the permission management logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I fixed a critical bug where CREATE, SHARE, and SHARE_PUBLIC permissions were being reset to defaults when using boolean configuration (e.g.,
agents: trueorprompts: true), overwriting admin panel customizations on application restart.librechat.yamlcreatefield support to permission configuration schemas, allowing explicit control over CREATE permissions alongside USEcreate,share, andpublicvalues from both boolean and object configurationsdomainSeparatorRegexcreation outside the loop to avoid redundant regex instantiationThe changes ensure that when
agents: trueis configured, only the USE permission is updated, treating it as a feature toggle. CREATE, SHARE, and SHARE_PUBLIC remain untouched in the database, preserving admin panel customizations. Whenagents: { create: false, share: true }is explicitly configured, only the specified permissions are updated, providing granular control over each permission type.Change Type
Testing
I verified the fix by writing and running three new regression tests that cover all permission configuration scenarios:
prompts: trueandagents: truepreserve existing CREATE/SHARE/SHARE_PUBLIC database values, only updating USEagents: { use: true, share: true, public: true }updates SHARE and SHARE_PUBLIC as expectedagents: { use: true, create: false }updates USE and CREATE while preserving existing SHARE/SHARE_PUBLIC valuesAll tests pass, confirming that admin panel permission changes are no longer overwritten on restart and that boolean configs function as intended feature toggles.
Test Configuration:
trueinterface.agents: true(only USE updated)interface.agents: { use: true, share: true, public: true }(all specified permissions updated)interface.agents: { use: true, create: false }(only USE and CREATE updated, SHARE/SHARE_PUBLIC preserved)Checklist
Relevant updated docs: LibreChat-AI/librechat.ai#497