Skip to content

🗂️ fix: Allow Empty-Overrides Scope Creation in Admin Config#12492

Merged
danny-avila merged 3 commits into
devfrom
claude/zen-wu
Apr 1, 2026
Merged

🗂️ fix: Allow Empty-Overrides Scope Creation in Admin Config#12492
danny-avila merged 3 commits into
devfrom
claude/zen-wu

Conversation

@danny-avila

Copy link
Copy Markdown
Owner

Summary

I fixed a bug in the upsertConfigOverrides handler where sending { overrides: {}, priority: N } from the admin panel to create a blank scope would short-circuit and return { message: ... } instead of creating the config document with { config: ... }. This caused the admin panel to fail with an _id error since it expected the response to contain the created config.

  • Adjust the early-return guard to only trigger when both overrides are empty and no priority is provided, allowing empty-overrides scope creation when a priority value is present.
  • Scope per-section permission checks to only run when override sections are actually present, relying on the existing general manage capability check for empty-override requests.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

  1. Open the admin panel and attempt to create a new blank config scope (empty overrides with a priority value).
  2. Verify the config document is created successfully and the admin panel does not throw an _id error.
  3. Verify that sending { overrides: {} } with no priority still returns the "No actionable override sections provided" message.
  4. Verify that sending overrides with unauthorized sections still returns a 403 error.

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • My changes do not introduce new warnings

The upsertConfigOverrides handler short-circuited when overrides was
empty, returning a plain message instead of creating the config document.
This broke the admin panel's "create blank scope" flow which sends
`{ overrides: {}, priority: N }` — the missing `config` property in the
response caused an `_id` error on the client.

The early return now only triggers when both overrides are empty and no
priority is provided. Per-section permission checks are scoped to cases
where override sections are actually present.
Copilot AI review requested due to automatic review settings April 1, 2026 01:18
@danny-avila
danny-avila changed the base branch from main to dev April 1, 2026 01:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an admin-config upsert edge case so the API can create a “blank” config scope when the admin panel sends empty overrides along with an explicit priority, returning a { config } payload as the UI expects.

Changes:

  • Update the upsertConfigOverrides early-return guard to only short-circuit when overrides are empty and priority is not provided.
  • Skip per-section permission checks when no override sections are present (empty overrides), relying on the existing broad manage capability check.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/api/src/admin/config.ts
Comment thread packages/api/src/admin/config.ts
@danny-avila

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- Add res.statusCode/res.body assertions to capability-check test
- Add 403/401 tests for empty overrides + priority path
- Use mockResolvedValue(null) for consistency on bare jest.fn()
- Remove narrating comment; fold intent into test name
@danny-avila
danny-avila merged commit f8405e7 into dev Apr 1, 2026
8 checks passed
@danny-avila
danny-avila deleted the claude/zen-wu branch April 1, 2026 01:46
jcbartle pushed a commit to jcbartle/LibreChat that referenced this pull request May 11, 2026
…vila#12492)

* fix: Allow empty-overrides scope creation when priority is provided

The upsertConfigOverrides handler short-circuited when overrides was
empty, returning a plain message instead of creating the config document.
This broke the admin panel's "create blank scope" flow which sends
`{ overrides: {}, priority: N }` — the missing `config` property in the
response caused an `_id` error on the client.

The early return now only triggers when both overrides are empty and no
priority is provided. Per-section permission checks are scoped to cases
where override sections are actually present.

* test: Add tests for empty-overrides scope creation with priority

* test: Address review nits for empty-overrides scope tests

- Add res.statusCode/res.body assertions to capability-check test
- Add 403/401 tests for empty overrides + priority path
- Use mockResolvedValue(null) for consistency on bare jest.fn()
- Remove narrating comment; fold intent into test name
ThomasVuNguyen pushed a commit to ThomasVuNguyen/LibreChat that referenced this pull request Jul 15, 2026
…vila#12492)

* fix: Allow empty-overrides scope creation when priority is provided

The upsertConfigOverrides handler short-circuited when overrides was
empty, returning a plain message instead of creating the config document.
This broke the admin panel's "create blank scope" flow which sends
`{ overrides: {}, priority: N }` — the missing `config` property in the
response caused an `_id` error on the client.

The early return now only triggers when both overrides are empty and no
priority is provided. Per-section permission checks are scoped to cases
where override sections are actually present.

* test: Add tests for empty-overrides scope creation with priority

* test: Address review nits for empty-overrides scope tests

- Add res.statusCode/res.body assertions to capability-check test
- Add 403/401 tests for empty overrides + priority path
- Use mockResolvedValue(null) for consistency on bare jest.fn()
- Remove narrating comment; fold intent into test name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants