fix(browser): resolve application/dotpage MIME filter to the HTMLPAGE base type (#36916) - #37032
fix(browser): resolve application/dotpage MIME filter to the HTMLPAGE base type (#36916)#37032ihoffmann-dot wants to merge 1 commit into
Conversation
|
Claude finished @ihoffmann-dot's task in 2m 0s —— View job SDK Compatibility Analysis
No SDK breaking change detected. The only production-code change is in Checked against every category in the reference doc:
The remaining changed files ( No comment or label added, per instructions for non-breaking changes. |
06749ef to
ed97477
Compare
Fixes #36916
Problem
The legacy "Select a file" / "Select link" dialog used to pick a redirect target page from a Page's Properties returned zero results for every folder — "No files found" even for folders that visibly contain pages.
BrowserAjax.getFolderContentWithDotAssets(...)came back as{total: 0, list: []}.application/dotpageis a synthetic, display-time-only MIME type. It is stamped onto a page's view map in memory (PageViewStrategy,ContentletAjax,BrowserAjax) and is never persisted tocontentlet_as_json. The SQL MIME predicate added in #34217 tests for an asset-metadatacontentType, so it matched zero HTMLPAGE rows and every page was filtered out in SQL before it could be transformed.Regression origin:
f4ff8039— "feat(Content Drive) #34205: Support mimeTypes filtering in /api/v1/drive/search endpoint" (#34217). That change targeted the new Content Drive endpoint but landed in the sharedselectQuery(...)path the legacy DWR browser also uses.Fix
BrowserAPIImpl.appendMIMETypeQuery(...)now routes each requested MIME type to the only clause that can actually match it, OR'd together inside the existingAND (...)wrapper:application/dotpage→struc.structuretype = BaseContentType.HTMLPAGE.getType()jsonb_path_exists(...)asset-metadata checkstrucis already joined bybuildSelectBaseQuery(...), so this needs no new join, no new bound parameter and no caller change.Why not simply exempt HTMLPAGE rows from the predicate
That was the spec's original idea and it was rejected during Phase 0 research. The in-memory
filterReturnList(...)pass runs on only one of the three consumers ofgetContentUnderParentFromDB(...)— Content Drive (/api/v1/drive/search) andgetFolderContentList(...)have no in-memory MIME filter at all. Exempting pages in SQL would have leaked pages intoimage/jpegbrowses on Content Drive, a new regression. The per-MIME translation is correct on all three paths and is a strictly smaller behavioural change.Generated SQL per request shape
mimeTypes["application/dotpage"]AND (struc.structuretype = 5)["image/jpeg"]AND (META(image/jpeg))— unchanged["application/dotpage","image/jpeg"]AND (struc.structuretype = 5 OR META(image/jpeg))["image/jpeg","application/pdf"]AND (META(image/jpeg) OR META(application/pdf))— unchangedFor any request that carries no
application/dotpage, the emitted fragment is byte-identical to before this PR. The5is emitted from theBaseContentType.HTMLPAGEenum, never written as a literal. The match on the synthetic value is exact, soapplication/dotpage-foostill takes the metadata branch.Testing
TDD, Red confirmed before any implementation. The Red run failed with exactly the expected signature — 5 failures, all and only the
application/dotpagecases, every one anAssertionErroron an empty result set:The real-MIME regression guards were green before and after.
After the fix:
BrowserAPITest40/40,BrowserAjaxTest7/7.New coverage:
BrowserAPITest—application/dotpagereturns pages;image/jpegreturns matching file assets and no pages;["image/jpeg","application/pdf"]unchanged;application/dotpage-foonot routed to base type; mixed request returns both; MIME order independence; nested sub-folder; language + default-language fallback.BrowserAjaxTest— the legacy DWR entry point the dialog actually calls.Browser_ResourcePostman collection — two new requests againstPOST /api/v1/browser(it had no MIME coverage at all).ContentDriveResourcealready covers MIME filtering and is untouched.Manual confirmation still pending: selecting a page in the dialog and saving it as a redirect target, and comparing the dialog listing against the Site Browser for the same folder.
Risk
Rollback-safe: no DB schema change, no ES mapping change, no REST/API contract change, no
@Schemachange, noopenapi.yamlregeneration, no data migration or reindex. One private method in one class.Out of scope
Flagged during planning, deliberately not fixed here:
appendMIMETypeQueryemits PostgreSQL-onlyjsonb_path_existswith no dialect branch — on MS SQL any MIME-filtered browse fails outright. Pre-existing, separate issue./api/v1/drive/searchendpoint #34217, unchanged here.PURE_ESpath builds its own+mimeType:(...)clause and has the same synthetic-MIME blind spot if it ever becomes the default heuristic. Not the default today.application/dotpagestring literals are left in place; only the modern class gets a constant.ADR alignment
ADR-0018 (Database-First Search for Content Drive, proposed) assigns MIME-type resolution to the DB via
jsonb_path_exists, scoped to file assets. This PR implements that scoping rather than deviating from it: MIME stays DB-resolved, and the asset-metadata check simply stops being applied to rows that structurally cannot carry asset metadata. Nothing moves to the index.🤖 Generated with Claude Code