Skip to content

Add test coverage for 'in' operator with tuple literals#512

Closed
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-matcher-bug-in-jcasbin
Closed

Add test coverage for 'in' operator with tuple literals#512
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-matcher-bug-in-jcasbin

Conversation

Copy link
Contributor

Copilot AI commented Feb 12, 2026

The in operator with tuple literals was reported as broken but the fix already exists in master. Adding regression test.

Changes

  • New test: InOperatorBugTest validates matcher expressions like:
    m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act || r.obj in ('data2', 'data3')

Test Coverage

Validates the conversion pipeline:

  • r.obj in ('data2', 'data3')include(tuple('data2', 'data3'), r.obj)
  • Role-based access with tuple bypass logic
  • Users without roles can access tuple-matched resources
  • Denial for values outside the tuple

The existing Util.convertInSyntax() correctly handles the conversion for Aviator compatibility. This test ensures the behavior doesn't regress.

Original prompt

This section details on the original issue you should resolve

<issue_title>[bug] 'in' of matcher doesn't work: "m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act || r.obj in ('data2', 'data3')"</issue_title>
<issue_description>link: https://editor.casbin.org/#4EVDCBGLC

model.conf:

[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[role_definition]
g = _, _

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act || r.obj in ('data2', 'data3')

OK in Node-Casbin:

Image

But in jcasbin:

Syntax error: invalid token at 64, lineNumber: 1, token : [type='Char',lexeme=',',index=64],
while parsing expression: `
g(r_sub, p_sub) && r_obj == p_obj && r_act == p_act || include((,^^^
`
, error: exit status 1

Image</issue_description>

Comments on the Issue (you are @copilot in this section)

@hsluoyz @lonelyxmas can you share the Casbin editor link? (click "SHARE" button) @hsluoyz @lonelyxmas click "SHARE", you will get a link like: https://editor.casbin.org/#5JLCGYDML

Image</comment_new>
<comment_new>@hsluoyz
@lonelyxmas can you try the copy-paste again? It should have been fixed</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI and others added 2 commits February 12, 2026 14:35
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix matcher bug in jcasbin for policy expression Add test coverage for 'in' operator with tuple literals Feb 12, 2026
Copilot AI requested a review from hsluoyz February 12, 2026 14:45
@hsluoyz hsluoyz marked this pull request as ready for review February 12, 2026 14:55
@hsluoyz hsluoyz closed this Feb 12, 2026
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.98%. Comparing base (c617f4d) to head (ba5b83f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #512   +/-   ##
=======================================
  Coverage   67.98%   67.98%           
=======================================
  Files          63       63           
  Lines        3089     3089           
  Branches      574      574           
=======================================
  Hits         2100     2100           
  Misses        805      805           
  Partials      184      184           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

[bug] 'in' of matcher doesn't work: "m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act || r.obj in ('data2', 'data3')"

4 participants