Replace deprecated browser metadata parser#18
Merged
ChrisAdamsdevelopment merged 1 commit intoMay 4, 2026
Merged
Conversation
Reviewer's GuideReplaces the deprecated browser-side metadata parser with the maintained music-metadata library, adding defensive limits and timeouts while preserving existing metadata extraction behavior and Quick Cleanse paths. Sequence diagram for updated browser metadata parsing with lazy loading and timeoutsequenceDiagram
title Browser_metadata_parsing_flow_with_lazy_loading_and_timeout
actor User
participant BrowserUI
participant MetadataUtils as metadata_js
participant MusicMetadata as music_metadata_library
User->>BrowserUI: Selects_audio_file
BrowserUI->>MetadataUtils: readFileMetadata(file)
MetadataUtils->>MetadataUtils: Check_file_size(file.size)
alt File_size_exceeds_MAX_BROWSER_PARSE_BYTES
MetadataUtils->>MetadataUtils: Throw_Error(File_too_large)
MetadataUtils-->>BrowserUI: Return_metadata({parseError, format, title, artist, genre, detectedMarkers, provenanceRisk, raw})
BrowserUI-->>User: Show_parse_error_and_continue_fallback
else File_size_within_limit
MetadataUtils->>MetadataUtils: getParseBlob()
alt First_time_load
MetadataUtils->>MusicMetadata: dynamic_import(music-metadata)
MusicMetadata-->>MetadataUtils: parseBlob_export
else Cached_loader
MetadataUtils-->>MetadataUtils: Reuse_cached_parseBlob
end
MetadataUtils->>MetadataUtils: withTimeout(parseBlob(file), PARSE_TIMEOUT_MS)
alt Parse_completes_before_timeout
MusicMetadata-->>MetadataUtils: Parsed_metadata
MetadataUtils->>MetadataUtils: Detect_markers_and_sanitize
MetadataUtils-->>BrowserUI: Return_metadata({format, title, artist, genre, detectedMarkers, provenanceRisk, raw})
BrowserUI-->>User: Proceed_with_metadata_driven_workflow
else Parse_times_out_or_throws
MusicMetadata-->>MetadataUtils: Error_or_timeout
MetadataUtils->>MetadataUtils: Set_parseError
MetadataUtils-->>BrowserUI: Return_metadata({parseError, format, title, artist, genre, detectedMarkers, provenanceRisk, raw})
BrowserUI-->>User: Show_parse_error_and_continue_fallback
end
end
note over BrowserUI,MetadataUtils: Quick_Cleanse_MP3_writing_still_uses_writeMP3Metadata_with_browser_id3_writer
Class diagram for updated metadata utilities using music-metadata with timeoutclassDiagram
class metadata_js {
<<module>>
+AI_MARKERS : string[]
+MARKER_REGEX_CACHE : Map
+MAX_BROWSER_PARSE_BYTES : number
+PARSE_TIMEOUT_MS : number
+getParseBlob() Promise
+withTimeout(promise, timeoutMs) Promise
+escapeRegex(value) string
+getMarkerRegex(marker) RegExp
+detectMarkersFromText(text) string[]
+detectMarkersFromFilename(name) string[]
+safeText(value) string
+readFileMetadata(file) Promise~MetadataResult~
+writeMP3Metadata(file, metadata) Promise~File~
}
class MusicMetadataLibrary {
<<external_library>>
+parseBlob(blob) Promise~ParsedMetadata~
}
class MetadataResult {
+format : any
+title : string
+artist : string
+genre : string
+detectedMarkers : string[]
+provenanceRisk : string
+raw : any
+parseError : Error
}
class QuickCleanseFlow {
<<browser_feature>>
+invokeQuickCleanse(file) void
}
class BrowserID3Writer {
<<external_library>>
+setFrame(frameId, value) BrowserID3Writer
+addTag() void
}
metadata_js ..> MusicMetadataLibrary : dynamic_import_music_metadata_and_use_parseBlob
metadata_js ..> MetadataResult : constructs
QuickCleanseFlow --> metadata_js : uses_writeMP3Metadata
metadata_js ..> BrowserID3Writer : uses_for_MP3_metadata_writing
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Motivation
music-metadata-browseris deprecated and pulled vulnerable nested parser deps, so browser-side metadata analysis was migrated to the maintainedmusic-metadatapackage while preserving the existing UX and app behavior.parseError, boundary-aware marker detection, filename marker scanning, and safe Quick Cleanse MP3 writing must be kept.Description
music-metadata-browserfrompackage.jsonand updated the parser adapter insrc/utils/metadata.jsto dynamically importmusic-metadataand resolveparseBlobwhile preserving the memoized lazy loader and originalreadFileMetadatareturn shape (format,title,artist,genre,detectedMarkers,provenanceRisk,raw,parseError).MAX_BROWSER_PARSE_BYTES = 100MB) that skips parsing and returns aparseError, and a parser timeout (PARSE_TIMEOUT_MS = 8000ms) implemented viawithTimeoutthat returns aparseErrorwhen triggered.safeTextsanitization, and the Quick Cleanse MP3 writer path (writeMP3Metadatausingbrowser-id3-writer) unchanged.package-lock.json,docs/manual-qa-checklist.md, andREADME.mdto remove the old deprecation note and document the newmusic-metadatausage and graceful-fallback behavior.Testing
npm installcompleted successfully andnpm run buildcompleted successfully (Vite build finished; frontend bundles produced).npm audit --jsonwas run and the post-change audit reports 2 moderate vulnerabilities; before/after diff was not captured in this run.npm outdated || truewas executed and produced informational output; build and install steps passed.package-lock.jsonno longer containsmusic-metadata-browser,src/utils/metadata.jsnow dynamically importsmusic-metadata,readFileMetadatastill catches parse failures and returns aparseErroron fallback, Quick Cleanse still useswriteMP3Metadata, and Full Server Cleanse (/api/process) and auth/Stripe/usage/API/Docker behaviors were not modified.Codex Task
Summary by Sourcery
Replace the deprecated browser metadata parser with the maintained music-metadata library while adding defensive limits and updating documentation and dependencies.
New Features:
Bug Fixes:
Enhancements:
Build:
Documentation: