aglinxinyuan opened a new pull request, #7479:
URL: https://github.com/apache/texera/pull/7479

   ### What changes were proposed in this PR?
   
   Every member of `DatasetSearchQueryBuilder` is `override protected`, so 
nothing is directly callable. The one public route in is the trait's `final 
constructQuery`, and what it returns can be rendered to SQL and inspected 
without ever executing it.
   
   That reaches the part of the file with real consequences: **which datasets a 
caller is allowed to see.**
   
   Adds 9 tests. The one that matters most is the grant join's scoping 
predicate — without `.eq(uid)` the `UID.isNotNull` check below is satisfied by 
any user's grant row, which hands the caller every shared dataset in the 
system. An anonymous caller must see public datasets only and match no grant 
row at all; a private-only search must not leak public datasets in.
   
   Also covers the keyword split, `selectDistinct` being the sole dedup (this 
builder alone has no `GROUP BY`, so the DISTINCT is all that collapses the rows 
the access join multiplies out), and the `'dataset'` literal that 
`DashboardResource` dispatches on with no default branch.
   
   **Verified by mutation**, all reverted (production diff empty):
   
   | Mutation | Result |
   |---|---|
   | grant join not scoped to the caller | red |
   | anonymous caller matches any grant row | red |
   | anonymous arm drops the public restriction | red |
   | private-only search leaks public datasets | red |
   | `includePublic` arm narrowed to public only | red |
   | keyword splitting removed | red |
   | a `GROUP BY` is introduced | red |
   | resource type mis-tagged | red |
   
   `toEntryImpl` is deliberately left uncovered — it is ~80% of this file's 
uncovered lines and sits behind a live LakeFS call with no mockable seam, so 
reaching it would need a source change rather than a test. That is stated in 
the spec's header so the next reader does not re-derive it.
   
   `MockTexeraDB` is initialized only because `SearchQueryBuilder.context` 
reads `SqlServer.getInstance()`; no query is run against the database.
   
   No production file is touched.
   
   ### Any related issues, documentation, discussions?
   
   Closes #7476
   
   ### How was this PR tested?
   
   ```
   sbt "WorkflowExecutionService/testOnly 
org.apache.texera.web.resource.dashboard.DatasetSearchQueryBuilderSpec"
   ```
   
   ```
   [info] Tests: succeeded 9, failed 0, canceled 0, ignored 0, pending 0
   [info] All tests passed.
   ```
   
   `Test/scalafmtCheck` and `Test/scalafix --check` both pass.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 5)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to