fix: log errors in writeShopifyIdToSheet and skip 404s in sync-stock

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-26 11:40:12 +02:00
parent a9850c8efd
commit d276f6224c
2 changed files with 17 additions and 4 deletions
+9 -2
View File
@@ -114,11 +114,14 @@ export async function writeShopifyIdToSheet(tab: string, rowNumber: number, shop
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', assertion: jwt }),
})
if (!tokenRes.ok) return
if (!tokenRes.ok) {
console.error(`[sheets] token error ${tokenRes.status} for ${tab}!A${rowNumber}`)
return
}
const { access_token } = await tokenRes.json() as { access_token: string }
const range = encodeURIComponent(`${tab}!A${rowNumber}`)
await fetch(
const writeRes = await fetch(
`https://sheets.googleapis.com/v4/spreadsheets/${sheetId}/values/${range}?valueInputOption=RAW`,
{
method: 'PUT',
@@ -126,6 +129,10 @@ export async function writeShopifyIdToSheet(tab: string, rowNumber: number, shop
body: JSON.stringify({ range: `${tab}!A${rowNumber}`, majorDimension: 'ROWS', values: [[shopifyId]] }),
},
)
if (!writeRes.ok) {
const txt = await writeRes.text()
console.error(`[sheets] write error ${writeRes.status} for ${tab}!A${rowNumber}: ${txt}`)
}
}
export async function fetchPendingProducts(