Repository navigation
Description
Reproducer
I tried this code (lofty 0.25.4):
use lofty::file::{AudioFile, TaggedFileExt};
use lofty::tag::{ItemKey, Tag, TagType};
fn main() {
// Any MP3 works; the tag below mimics what Picard writes (TXXX:WORK).
let mut tagged = lofty::read_from_path("in.mp3").unwrap();
tagged.clear();
let mut tag = Tag::new(TagType::Id3v2);
tag.insert_text(ItemKey::TrackTitle, "Title".to_string());
tag.insert_text(ItemKey::Work, "Example Work".to_string());
tagged.insert_tag(tag);
tagged
.save_to_path("out.mp3", lofty::config::WriteOptions::default())
.unwrap();
}Result, including the full error chain:
failed to write Mpeg file
caused by: failed to write Id3v2 tag
caused by: failed to write frame 'WORK'
caused by: a value of type 'Text' cannot be written under this ID
The save is all-or-nothing, so one Work item makes the whole file unwritable through the generic Tag API. This bites on real-world input: Picard writes the work name as TXXX:WORK, and any MP3 already carrying that frame fails a generic round-trip save (read maps TXXX:WORK to ItemKey::Work, then the write below aborts).
Summary
ItemKey::Work is routed through the multi-valued text-frame arm in src/id3/v2/tag/conversion.rs, and ItemKey::map_key(Work, TagType::Id3v2) returns "WORK". That combination builds a Frame::Text with the literal id WORK, which verify_frame in src/id3/v2/write/frame.rs rejects (Text is only valid under T*/known ids). So the Work key is unencodable on the ID3v2 path by construction.
Same-class instance: ItemKey::FlagPodcast with a "1"/"0" value builds a Frame::Text with id PCST and aborts with the identical chain (failed to write frame 'PCST'). For reference, mutagen models PCST as a 4-byte integer frame, never text, so the Text construction cannot be right there either. (Other FlagPodcast spellings are silently discarded by flag_item, which is at least non-fatal.)
Expected behavior
Work should round-trip as TXXX:WORK, matching the read side ("WORK" => Work in src/tag/item.rs) and Picard/mutagen interop. Suggested patch (moves Work into the multi-valued TXXX arm, which emits new_user_text_frame("WORK", value)):
--- a/src/id3/v2/tag/conversion.rs
+++ b/src/id3/v2/tag/conversion.rs
@@ -135,7 +135,6 @@
| ItemKey::InternetRadioStationName
| ItemKey::InternetRadioStationOwner
| ItemKey::Remixer
- | ItemKey::Work
| ItemKey::Movement
| ItemKey::MovementNumber
| ItemKey::MovementTotal
@@ -164,6 +163,7 @@
| ItemKey::MusicBrainzReleaseType
| ItemKey::MusicBrainzTrackId
| ItemKey::MusicBrainzReleaseId
| ItemKey::MusicBrainzReleaseGroupId
+ | ItemKey::Work
| ItemKey::ReleaseCountry
| ItemKey::Barcode
| ItemKey::Color => {No asset file is needed; the snippet above reproduces against any MP3. Happy to split the PCST half into its own issue if you prefer; I kept it here since it is the same verify-class failure.
Activity
fix: a file carrying a work title can be written again (#351)
milesegan commentedon Oct 1, 2026
I ran into this one too.