Skip to content

Fails to read id3v2.3 tag written by lofty if picture description is None #653

Closed

Description

@dunkyl

Reproducer

I tried this code:

(provided a path to an mp3 file with a cover image!)

use lofty::{file::TaggedFileExt, tag::TagExt};

fn main() {
    let args = std::env::args().collect::<Vec<_>>();
    let path = &args[1];

    let tagged = lofty::probe::read_from_path(path).unwrap();
    let mut tag = tagged.primary_tag().or(tagged.first_tag()).unwrap().clone();

    let new_path = path.replace(".mp3", ".2.mp3");
    std::fs::copy(path, &new_path).unwrap();
    {
        let mut pic = tag.remove_picture(0);
        pic.set_description(None);
        tag.push_picture(pic);
   }
    tag.save_to_path(
        &new_path,
        lofty::config::WriteOptions::new().use_id3v23(true),
    )
    .unwrap();

    println!("--- rewrote tag");

    let tagged = lofty::probe::read_from_path(new_path);

    match tagged {
        Ok(_) => println!("reread OK"),
        Err(e) => println!("reread err: {:?}", e),
    }
}

panics should be unrelated to this particular issue, the expected output for this issue is reread err: TextDecode("UTF-16 string has an invalid byte order mark").

Summary

When writing a picture with the id3v2.3 option, and when a picture has None as description, lofty then can't read the tags it wrote. For the reproducing code above, I added some lines to remove the picture description, but if the input file is already missing it, then the issue occurs even if the unmodified Tag is saved. Commenting out the block should still reproduce it with the attached file, for example.

It seems like certain files written by other software as id3v2.3 and without picture descriptions read OK. It seems like most other software can read the other tags, if present, but only some can still read the picture.

Expected behavior

Can probe the tags without a text decode error.

Assets

Aaron Cherof - Holga Date - 01 I Love This Place.mp3

Activity

  1. added
    bug
    on May 2, 2026
  2. Serial-ATA commented on May 2, 2026

    @Serial-ATA
    Owner

    Thanks! I think I ran into this before and completely forgot to fix it 🤦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions