QuantumNous/new-api · error · Error
Failed to preview upstream diff
Error message
Failed to preview upstream diff
What it means
Thrown by handleSync in the models sync wizard when previewUpstreamDiff({ locale, source }) resolves with success=false. The preview step fetches the diff against the selected upstream source before applying; failure aborts the wizard before conflict handling.
Source
Thrown at web/src/features/models/components/dialogs/sync-wizard-dialog.tsx:86
const preferredSource = SYNC_SOURCE_OPTIONS.find(
(option) => option.value === syncWizardOptions.source
)
setSource(
preferredSource && !preferredSource.disabled
? (preferredSource.value as SyncSource)
: 'official'
)
}
}, [open, syncWizardOptions, SYNC_SOURCE_OPTIONS])
const handleSync = async () => {
setIsSyncing(true)
try {
setSyncWizardOptions({ locale, source })
const previewRes = await previewUpstreamDiff({ locale, source })
if (!previewRes.success) {
throw new Error(previewRes.message || 'Failed to preview upstream diff')
}
const conflicts = previewRes.data?.conflicts || []
if (conflicts.length > 0) {
toast.warning(
`Found ${conflicts.length} conflict${conflicts.length > 1 ? 's' : ''}. Please resolve them first.`
)
setUpstreamConflicts(conflicts)
setOpen('upstream-conflict')
return
}
// No conflicts, proceed with sync
const response = await syncUpstream({ locale, source })
if (response.success) {
const { created_models, created_vendors, updated_models } =View on GitHub (pinned to e2c7aa7b10)
Solutions
- Retry after a short wait if the upstream rate-limited (common with anonymous GitHub API)
- From the backend host, verify reachability of the chosen source endpoint (curl)
- Try a different source option in the wizard (e.g. switch mirror) to isolate a dead upstream
- Check backend logs for the exact upstream status code returned to previewUpstreamDiff
Example fix
// before
const previewRes = await previewUpstreamDiff({ locale, source })
if (!previewRes.success) {
throw new Error(previewRes.message || 'Failed to preview upstream diff')
}
// after - keep the wizard open and show a retryable error state
const previewRes = await previewUpstreamDiff({ locale, source })
if (!previewRes.success) {
setSyncError(previewRes.message || 'Failed to preview upstream diff')
return
} Defensive patterns
Strategy: retry
Validate before calling
if (!source) { toast.error(t('Select a source first')); return }
if (!locale) { toast.error(t('Select a locale first')); return } Try / catch
setIsSyncing(true)
try {
const previewRes = await previewUpstreamDiff({ locale, source })
if (!previewRes.success) {
throw new Error(previewRes.message || 'Failed to preview upstream diff')
}
const conflicts = previewRes.data?.conflicts || []
if (conflicts.length > 0) {
setUpstreamConflicts(conflicts)
setOpen('upstream-conflict')
return
}
} catch (error) {
toast.error(error instanceof Error ? error.message : 'Failed to preview upstream diff')
} finally {
setIsSyncing(false)
} Prevention
- Retry once with backoff — upstream rate limits are the most transient cause
- Offer a source switcher so a dead mirror does not block the wizard
- Keep setIsSyncing(false) in finally so the button re-enables after failure
When it happens
Trigger: Starting a sync with source 'official' (or another option) where the backend cannot fetch the upstream model listing — GitHub rate limit, upstream repo/mirror unreachable, invalid locale — or the request rejects (session expired).
Common situations: Backend has no outbound internet / DNS failure to the upstream host; upstream API rate-limited anonymous requests; locale value not supported; backend version predates the sync endpoint.
Related errors
- No models fetched from upstream
- Failed to fetch usage
- Failed to fetch usage
- Failed to fetch reset credit details
- Failed to reset usage
AI-assisted analysis of QuantumNous/new-api@e2c7aa7b10 (2026-08-15).
Data as JSON: /api/errors/49af3514bcc87c5a.
Report an issue: GitHub.