Apps: normalize filetype associations to bare lowercase extensions - #3479
Merged
Conversation
Suggested-apps lookups match app_filetype_association rows against the
bare lowercase extension ('docx'), but writes stored whatever the
developer typed. Rows like '.docx' never matched, so those apps
silently dropped out of Open With suggestions.
AppStore now canonicalizes on write (trim, lowercase, strip leading
dots, dedupe, drop empties) and tolerates the dotted legacy form on
read: getAppsByFiletype normalizes the requested extension, matches
both 'docx' and '.docx', and dedupes apps associated under both forms.
Cache invalidation keys are normalized the same way. Existing dotted
rows work without a data migration.
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
Adjust apps API tests to match current normalization behavior for `filetypeAssociations`: extension values are stored as lowercase bare extensions (e.g. `.txt` -> `txt`), while MIME types remain unchanged. Added inline comments in both test suites to document this expected remap.
Contributor
Coverage Report for puter.js SDK
File CoverageNo changed files found. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Apps with filetype associations stored in dotted form (e.g.
.docx) never show up in the Open With menu or other app suggestions for matching files.SuggestedAppsServiceextracts the bare lowercase extension from the filename (docx) andAppStore.getAppsByFiletypematchedapp_filetype_association.typeagainst it with an exact equality check. But the write path (setFiletypeAssociations, fed by Dev Center /puter-jsapp create/update) stored whatever string the developer typed, verbatim. Anyone who entered.docxinstead ofdocxgot association rows that could never match, and their app silently dropped out of suggestions. In production roughly one fifth of all association rows are stored in the dotted form, so this is a common failure mode (it is howword-processorwent missing from Open With for doc/docx files).Fix
Both sides are handled in
AppStore, the single choke point for reads and writes:setFiletypeAssociationsnow trims, lowercases, strips leading dots, dedupes, and drops entries that normalize to nothing before inserting. Cache invalidation keys are normalized the same way.getAppsByFiletypenormalizes the requested extension, matches both the bare and dotted forms (docxand.docx), and dedupes apps associated under both. Existing dotted rows start working immediately, no data migration required. A follow-up cleanup migration of legacy rows is possible later but no longer a prerequisite.Tests
AppStore.test.jscovering write canonicalization, empty-input handling, legacy dotted-row matching, both-forms dedupe, requested-extension normalization, and empty-extension behavior.AppDrivertests that asserted the old verbatim round-trip of dotted input.AppStore,AppDriver, andSuggestedAppsServicesuites pass (101 tests).