From f78be94c67e1f88301449377d95f79d4b374cca1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 31 Mar 2026 19:30:17 +0000 Subject: [PATCH] Fix collection uploads to fail on partial track publish Co-authored-by: Ray Jacobson --- .../tan-query/upload/usePublishCollection.ts | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/packages/common/src/api/tan-query/upload/usePublishCollection.ts b/packages/common/src/api/tan-query/upload/usePublishCollection.ts index fd1a86d3130..71215523804 100644 --- a/packages/common/src/api/tan-query/upload/usePublishCollection.ts +++ b/packages/common/src/api/tan-query/upload/usePublishCollection.ts @@ -92,6 +92,15 @@ const getPublishCollectionOptions = (context: PublishCollectionContext) => params.tracks ) + const failedTracks = publishedTracks.filter( + (track) => track.error || !track.trackId + ) + if (failedTracks.length > 0) { + throw new Error( + `Failed to publish ${failedTracks.length} of ${params.tracks.length} collection tracks` + ) + } + // For collection artwork, use the existing flow (not TUS) to keep things simple for now. const { artwork } = params.collectionMetadata const artworkBlob = @@ -103,13 +112,11 @@ const getPublishCollectionOptions = (context: PublishCollectionContext) => const metadata = albumMetadataForCreateWithSDK( params.collectionMetadata ) - metadata.playlistContents = publishedTracks - .filter((t) => !!t.trackId) - .map((t) => ({ - timestamp: Math.round(Date.now() / 1000), - trackId: t.trackId!, - metadataTimestamp: Math.round(Date.now() / 1000) - })) + metadata.playlistContents = publishedTracks.map((track) => ({ + timestamp: Math.round(Date.now() / 1000), + trackId: track.trackId!, + metadataTimestamp: Math.round(Date.now() / 1000) + })) return await sdk.albums.createAlbum({ userId: Id.parse(userId), imageFile: coverArtFile, @@ -119,13 +126,11 @@ const getPublishCollectionOptions = (context: PublishCollectionContext) => const metadata = playlistMetadataForCreateWithSDK( params.collectionMetadata ) - metadata.playlistContents = publishedTracks - .filter((t) => !!t.trackId) - .map((t) => ({ - timestamp: Math.round(Date.now() / 1000), - trackId: t.trackId!, - metadataTimestamp: Math.round(Date.now() / 1000) - })) + metadata.playlistContents = publishedTracks.map((track) => ({ + timestamp: Math.round(Date.now() / 1000), + trackId: track.trackId!, + metadataTimestamp: Math.round(Date.now() / 1000) + })) return await sdk.playlists.createPlaylist({ userId: Id.parse(userId), imageFile: coverArtFile,