Skip to content

🧩 fix: Support DocumentDB Prompt Group Lookup#13232

Merged
danny-avila merged 3 commits into
devfrom
danny-avila/fix-prompt-group-documentdb-lookup
May 21, 2026
Merged

🧩 fix: Support DocumentDB Prompt Group Lookup#13232
danny-avila merged 3 commits into
devfrom
danny-avila/fix-prompt-group-documentdb-lookup

Conversation

@danny-avila

@danny-avila danny-avila commented May 21, 2026

Copy link
Copy Markdown
Owner

Summary

I split the prompt-group DocumentDB compatibility fix into its own PR and kept it scoped to getPromptGroup lookup behavior.

  • Replaced the tenant-scoped $lookup form that used let and pipeline with a simple localField/foreignField lookup that is compatible with DocumentDB-style lookup support.
  • Preserved tenant safety by clearing productionPrompt after the join when a non-system tenant context sees a joined prompt from a different tenant.
  • Added MongoMemoryServer regression coverage for tenant-matching, tenant-mismatch, system-tenant, missing group, string _id, and the emitted lookup shape.
  • Added explain-based coverage proving the group match and production prompt lookup use indexed _id execution paths, including _id_ for the joined prompt and totalDocsExamined <= 1 for that lookup.
  • Added type-safe pipeline inspection in the regression test so the data-schemas TypeScript check passes.

Change Type

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

Testing

  • npx jest --runTestsByPath src/methods/prompt.spec.ts src/methods/prompt.getPromptGroup.spec.ts --runInBand --coverage=false
  • npx tsc --noEmit -p packages/data-schemas/tsconfig.json
  • npm run build:data-schemas
  • git diff --check

Test Configuration:

  • Local compatibility and execution-plan coverage uses mongodb-memory-server.
  • The lookup assertion verifies getPromptGroup does not emit $lookup.let or $lookup.pipeline.
  • The explain assertion verifies the one-group match uses an indexed _id plan and the production prompt lookup uses the _id_ index with totalDocsExamined <= 1.

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
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

Copilot AI review requested due to automatic review settings May 21, 2026 17:55
@danny-avila

Copy link
Copy Markdown
Owner Author

@codex review

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

This PR updates getPromptGroup’s aggregation to use a DocumentDB-compatible $lookup shape while preserving tenant isolation semantics, and adds regression tests to prevent reintroducing the unsupported lookup form.

Changes:

  • Replaced $lookup using let/pipeline with a localField/foreignField join for DocumentDB compatibility.
  • Preserved tenant safety by nulling productionPrompt when a non-system tenant joins a prompt from another tenant.
  • Added Jest coverage for tenant match/mismatch, system tenant behavior, missing groups, string _id casting, and the emitted $lookup shape.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/data-schemas/src/methods/prompt.ts Switched getPromptGroup aggregation to DocumentDB-compatible $lookup and added post-join tenant guard.
packages/data-schemas/src/methods/prompt.getPromptGroup.spec.ts Added regression tests for tenancy behavior and to assert $lookup does not use let/pipeline.

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

Comment thread packages/data-schemas/src/methods/prompt.getPromptGroup.spec.ts Outdated
Comment thread packages/data-schemas/src/methods/prompt.getPromptGroup.spec.ts Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ 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".

@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. Swish!

ℹ️ 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".

@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13232 index is now live on the MCP server.
Deploy run

@danny-avila
danny-avila marked this pull request as ready for review May 21, 2026 18:19
@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. Delightful!

ℹ️ 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".

@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13232 index is now live on the MCP server.
Deploy run

@danny-avila
danny-avila changed the base branch from main to dev May 21, 2026 19:10
@danny-avila
danny-avila merged commit d7482eb into dev May 21, 2026
10 checks passed
@danny-avila
danny-avila deleted the danny-avila/fix-prompt-group-documentdb-lookup branch May 21, 2026 19:11
fuuuzzy pushed a commit to fuuuzzy/LibreChat that referenced this pull request May 22, 2026
* fix: support DocumentDB prompt group lookup

* test: address prompt group review feedback

* test: prove prompt group indexed lookup
ThomasVuNguyen pushed a commit to ThomasVuNguyen/LibreChat that referenced this pull request Jul 15, 2026
* fix: support DocumentDB prompt group lookup

* test: address prompt group review feedback

* test: prove prompt group indexed lookup
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