Skip to content

Commit 54d23c0

Browse files
committed
catch 409 errors for existing mappings
Update hf.ts
1 parent 09e9d7b commit 54d23c0

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/hf.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,18 @@ class HFInferenceProviderClient {
5454

5555
if (!response.ok) {
5656
const errorText = await response.text();
57-
throw new Error(`Request failed: ${response.status} ${response.statusText} - ${errorText}`);
57+
const error = new Error(`Request failed: ${response.status} ${response.statusText} - ${errorText}`);
58+
if (response.status !== 409) {
59+
console.error('Request error:', error);
60+
}
61+
throw error;
5862
}
5963

6064
return await response.json();
6165
} catch (error) {
62-
console.error('Request error:', error);
66+
if (error instanceof Error && !error.message.includes('409 Conflict')) {
67+
console.error('Request error:', error);
68+
}
6369
throw error;
6470
}
6571
}

src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,15 @@ if (inferenceTags.length > 0) {
7272
console.log("\n\nAdding tag mappings:");
7373
for (const tag of inferenceTags) {
7474
console.log(`${tag.tags.join(', ')} - ${tag.status ?? 'live'}`);
75-
await hf.registerMappingItem(tag);
75+
try {
76+
await hf.registerMappingItem(tag);
77+
} catch (error) {
78+
if (error instanceof Error && error.message.includes('409 Conflict')) {
79+
console.log(`Skipping existing mapping for tags: ${tag.tags.join(', ')}`);
80+
continue;
81+
}
82+
throw error;
83+
}
7684
}
7785
} else {
7886
console.log("\n\nNo tag mappings to add.");

0 commit comments

Comments
 (0)