fix(content): address Gemini review — error checks, auth consistency

7 fixes from code review:
- Add image download error checks in haiper/leonardo/ideogram handlers
- Add audio download error checks in suno/udio handlers
- Use providerConfig.statusUrl for suno polling (not hardcoded URL)
- Fix suno authType to "cookie" in providerRegistry

Co-Authored-By: OpenClaude (mimo-v2.5-pro) <openclaude@gitlawb.com>
This commit is contained in:
oyi77
2026-05-19 00:12:55 +07:00
parent 32b3549425
commit 6401faf9f0
3 changed files with 38 additions and 3 deletions

View File

@@ -1986,7 +1986,7 @@ export const REGISTRY: Record<string, RegistryEntry> = {
format: "openai",
executor: "default",
baseUrl: "https://studio-api.suno.ai/api/generate/v2/",
authType: "apikey",
authType: "cookie",
authHeader: "cookie",
models: [
{ id: "chirp-v3-5", name: "Chirp V3.5" },

View File

@@ -3018,7 +3018,7 @@ async function handleHaiperImageGeneration({
const res = await fetch(providerConfig.baseUrl, {
method: "POST",
headers: { "Content-Type": "application/json", HAIPER_KEY: token },
body: JSON.stringify({ prompt, aspect_ratio: "16:9" }),
body: JSON.stringify({ prompt, aspect_ratio: body.aspect_ratio || "16:9" }),
});
if (!res.ok) {
const errorText = await res.text();
@@ -3045,6 +3045,13 @@ async function handleHaiperImageGeneration({
const imgUrl = status.creation_url || status.output?.image_url;
if (imgUrl) {
const imgRes = await fetch(imgUrl);
if (!imgRes.ok) {
return {
success: false,
status: imgRes.status,
error: `Failed to download image: ${imgRes.status}`,
};
}
const buf = await imgRes.arrayBuffer();
saveCallLog({
method: "POST",
@@ -3166,6 +3173,13 @@ async function handleLeonardoImageGeneration({
const imgUrl = gen.generated_images?.[0]?.url;
if (imgUrl) {
const imgRes = await fetch(imgUrl);
if (!imgRes.ok) {
return {
success: false,
status: imgRes.status,
error: `Failed to download image: ${imgRes.status}`,
};
}
const buf = await imgRes.arrayBuffer();
saveCallLog({
method: "POST",
@@ -3259,6 +3273,13 @@ async function handleIdeogramImageGeneration({
if (data.data && data.data.length > 0) {
const imgUrl = data.data[0].url;
const imgRes = await fetch(imgUrl);
if (!imgRes.ok) {
return {
success: false,
status: imgRes.status,
error: `Failed to download image: ${imgRes.status}`,
};
}
const buf = await imgRes.arrayBuffer();
saveCallLog({
method: "POST",

View File

@@ -434,13 +434,20 @@ async function handleSunoMusicGeneration({
const deadline = Date.now() + 300000;
while (Date.now() < deadline) {
await new Promise((r) => setTimeout(r, 5000));
const feedRes = await fetch(`https://studio-api.suno.ai/api/feed/?ids=${ids.join(",")}`, {
const feedRes = await fetch(`${providerConfig.statusUrl}?ids=${ids.join(",")}`, {
headers: { Cookie: cookie },
});
const songs = await feedRes.json();
const ready = songs.filter((s) => s.audio_url);
if (ready.length > 0) {
const audioRes = await fetch(ready[0].audio_url);
if (!audioRes.ok) {
return {
success: false,
status: audioRes.status,
error: `Failed to download audio: ${audioRes.status}`,
};
}
const buf = await audioRes.arrayBuffer();
saveCallLog({
method: "POST",
@@ -545,6 +552,13 @@ async function handleUdioMusicGeneration({
const ready = songs.filter((s) => s.finished && s.song_path);
if (ready.length > 0) {
const audioRes = await fetch(ready[0].song_path);
if (!audioRes.ok) {
return {
success: false,
status: audioRes.status,
error: `Failed to download audio: ${audioRes.status}`,
};
}
const buf = await audioRes.arrayBuffer();
saveCallLog({
method: "POST",