This is due to `BLI_findstring` returning wrong id from passed name. Two IDs can have same name before making them unique so it can return wrong id. To fix this, pass id argument instead of id_name to `BLI_libblock_ensure_unique_name` and skip the use of `BLI_findstring` Pull Request: https://projects.blender.org/blender/blender/pulls/116246