Skip to content

fix: add has trap to client proxy for in operator support#26

Open
ktmouk wants to merge 1 commit intocodepunkt:mainfrom
ktmouk:fix/add-has-trap-to-client-proxy
Open

fix: add has trap to client proxy for in operator support#26
ktmouk wants to merge 1 commit intocodepunkt:mainfrom
ktmouk:fix/add-has-trap-to-client-proxy

Conversation

@ktmouk
Copy link

@ktmouk ktmouk commented Mar 16, 2026

Summary

  • The client Proxy was missing a has trap, so the in operator (e.g. "chapter" in client) always returned false — this broke libraries like Pothos Prisma plugin that rely on in to check for delegate existence
  • Added a has trap that delegates to transactionClient when active, or returns false when no transaction is active

Test plan

  • has trap returns true for existing properties and false for non-existent properties during active transaction
  • has trap returns false when no transaction is active
  • All existing tests pass, 100% coverage maintained

Summary by CodeRabbit

  • Tests

    • Added test cases validating proxy trap behavior for existing and non-existent properties, and proper handling when no active transaction is present.
  • Improvements

    • Enhanced proxy property existence checking to correctly handle scenarios when no active transaction is present.

@coderabbitai
Copy link

coderabbitai bot commented Mar 16, 2026

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'review'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

This pull request adds test validation for proxy trap behavior and implements a "has" trap in the Prisma client proxy that returns false when no active transaction exists, otherwise delegating to the transaction client for property existence checks.

Changes

Cohort / File(s) Summary
Test Validation
src/contest.test.ts
Adds two test cases verifying trap behavior: confirms trap returns true for existing properties ('$connect' and meta) and false for non-existent properties; validates trap returns false when no active transaction exists.
Proxy Implementation
src/context.ts
Implements a "has" trap on the Prisma client proxy that checks for active transaction client; returns false when none exists, otherwise delegates to transaction client to determine property existence.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰✨ A trap so clever, a "has" so neat,
The proxy checks before we meet,
Transaction client takes the call,
When active—or returns false to all! 🎭

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a has trap to the client proxy for in operator support, which is the core fix implemented in the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.

OpenGrep is compatible with Semgrep configurations. Add an opengrep.yml or semgrep.yml configuration file to your project to enable OpenGrep analysis.

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.

1 participant