feat(policy): add search support to ListSubjectMappings - #3555
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds search filtering to ChangesSubject Mappings Search Implementation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces search capabilities to the ListSubjectMappings RPC. By integrating a new filtering layer into the underlying SQL query, the system now supports searching across multiple fields, including attribute FQNs, actions, and complex condition structures. This change improves the discoverability of subject mappings and includes robust integration tests to ensure search and pagination work as expected. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. The search is on, the query wide, With SQL logic as our guide. From FQN to action name, We find the mappings in the frame. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request implements search functionality for listing subject mappings, allowing filtering by FQNs, actions, and nested JSONB conditions. It also adds comprehensive integration tests to verify the search behavior, including pagination and namespace combinations. A critical review comment points out a potential PostgreSQL runtime error when parsing JSONB keys that contain JSON null values, which can cause JSONB_ARRAY_ELEMENTS to fail on a scalar. It is recommended to use jsonb_typeof to verify that the JSONB values are arrays before expanding them.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
6242e56 to
f0cdc22
Compare
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Signed-off-by: Chris Reed <creed@virtru.com>
Signed-off-by: Chris Reed <creed@virtru.com>
Signed-off-by: Chris Reed <creed@virtru.com>
a8e79d0 to
1a8d75b
Compare
X-Test Failure Report |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@service/policy/db/queries/subject_mappings.sql`:
- Around line 132-139: The FQN search branch uses a case-sensitive LIKE, so
update the predicate that references fqns.fqn in the filtered_subject_mappings
query to perform a case-insensitive match (e.g., change the fqns.fqn LIKE
sqlc.narg('search')::TEXT ESCAPE '\' to use ILIKE or wrap with LOWER on both
sides) so it matches the lowercased bound search parameter from
sqlc.narg('search')::TEXT; ensure the change is applied in the same CASE branch
alongside the existing JSONB label ILIKE check.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 9df402c6-98a1-4741-bc07-7e07099e0bee
📒 Files selected for processing (4)
service/integration/subject_mappings_test.goservice/policy/db/queries/subject_mappings.sqlservice/policy/db/subject_mappings.goservice/policy/db/subject_mappings.sql.go
Invalidated by push of 7dacd7f
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
|
## Summary - Adds ListSubjectMappings RPC search support by wiring request search into the policy DB list query. - Applies escaped, case-insensitive matching in the subject mappings SQL path and adds integration coverage for search behavior, wildcard literals, empty search, and pagination after filtering. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Subject mappings now support search filtering by attribute values and metadata labels * Search results can be combined with namespace filters for refined queries * Automatic whitespace trimming and special character handling ensure accurate searches * Result pagination works correctly with all filters applied <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Chris Reed <creed@virtru.com>
Summary
Summary by CodeRabbit