[Grid] Fix 404 when grid search is anchored on the root folder#1931
Closed
xIrusux wants to merge 1 commit into
Closed
[Grid] Fix 404 when grid search is anchored on the root folder#1931xIrusux wants to merge 1 commit into
xIrusux wants to merge 1 commit into
Conversation
The grid endpoints resolve the request's folderId through the permission-aware search index to derive the path filter. The root folder (id 1) is not necessarily visible there: restricted user workspaces exclude "/", and a rebuilt index may miss the root document. Any grid request anchored on the root (e.g. the data quality score widget drill-down) then failed with "DataObject with ID: 1 not found". The root folder always exists and its path is "/" by definition, so skip the index lookup for it. Results remain permission-filtered by the search query itself. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| UnusedCode | 1 medium |
| BestPractice | 2 medium |
| CodeStyle | 11 minor |
| Complexity | 1 medium |
🟢 Metrics 4 complexity
Metric Results Complexity 4
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
On studionightly, clicking a bar in the data quality score widget (drill-through) fails:
Root cause
The DQ drill-down grid is class-scoped, not folder-scoped, so the frontend anchors it on the root folder and sends
folderId: 1(which is also the only option —folderIdis a required field of the grid request body).GridSearch::setFilterPath()resolves thatfolderIdthrough the permission-aware search index (getDataObjectById(1, $user)→ GDIbyId()withPermissionTypes::VIEW+ the user's workspace query) purely to derive the path filter.The root folder is not reliably visible through that lookup:
/Product Dataonly), the root's path/matches nothing →null→NotFoundException('DataObject', 1)→ the observed 404.This is why it worked in dev (admin user, root indexed) and broke in production.
Fix
The root folder always exists and its full path is
/by definition — no lookup is needed.setFilterPath()now short-circuits forfolderId === ElementFolderIds::ROOT->valueand sets the path filter to/directly. This applies to all three element types (asset/object/document roots are all id 1).Security note: the removed lookup acted as an implicit "can you see this folder" gate — but only for the root. The path filter
/is pure scoping (matches everything); the result set is still filtered by the user's workspace query inside the search itself, so restricted users see exactly what they are allowed to see and nothing more. A user with no workspace gets an empty grid, not a 404.Regression test
tests/Unit/DataIndex/Grid/GridSearchTest.php:folderId = 1must not call the index lookup and must produce a/path filter (red before the fix — failed on the exactgetDataObjectById(1, …)call from the production stack trace).folderId ≠ 1still resolves the folder path through the index (pins existing behavior).Verified: bundle unit suite green (418 tests, 966 assertions), PHPStan clean.
Propagation
setFilterPath()is byte-identical on2025.4,2026.1,2026.2and2026.x— this needs the usual forward-merge up the chain (studionightly runs the newest line).No frontend change needed: the DQ widget's
ROOT_FOLDER_ID = 1anchor becomes legitimate once the backend stops requiring root visibility.🤖 Generated with Claude Code