Skip to content

fix: stop swallowing exceptions in import fire-and-forget pipeline runners#176

Open
davidortinau wants to merge 4 commits into
mainfrom
op-fix-import-catch-swallow
Open

fix: stop swallowing exceptions in import fire-and-forget pipeline runners#176
davidortinau wants to merge 4 commits into
mainfrom
op-fix-import-catch-swallow

Conversation

@davidortinau
Copy link
Copy Markdown
Owner

Problem

Three fire-and-forget Task.Run blocks in the import/channel endpoints had empty catch bodies with a misleading comment:

catch (Exception ex)
{
    // Logging happens inside the pipeline service
}

This comment is incorrect for exceptions thrown before the pipeline service's own try/catch (e.g. DI resolution failures, scope creation errors, the first pipeline step). When that happens:

  • ex is silently discarded
  • The import record is never updated to Failed
  • The caller polling /api/imports/{id} sees the import permanently stuck in Pending

Fix

Replace the empty catch with logging + status update in all three call sites:

catch (Exception ex)
{
    logger.LogError(ex, "Unhandled exception in import pipeline for import {ImportId}", import.Id);
    await pipelineService.FailImportAsync(import, ex.Message);
}

Changes

  • VideoImportPipelineService.cs — promoted FailImportAsync from private to public so endpoint handlers can call it
  • ImportEndpoints.csStartImport and RetryImport catch blocks now log the error and mark the import failed
  • ChannelEndpoints.cs — channel video trigger loop catch block gets the same fix

Verification

  • dotnet build src/SentenceStudio.Api/ — ✅ clean (0 errors)
  • dotnet test tests/SentenceStudio.Api.Tests/ — 120 pass; 19 failures are pre-existing on main (IChatClient not registered in auth test DI harness, unrelated to this change)

davidortinau and others added 4 commits April 24, 2026 10:57
- Orchestration log: DX24 vocab crash fix workflow (commit c9b1d0a)
- Session log: ExposureCount NULL→0 backfill, verified on device
- Decision merge: inbox → decisions.md (3 entries: lexical patch, validation strategy, directive)
- Deleted: inbox files + jayne-locale-screenshots (deduped)
- Wash history: append CRITICAL RULE for SQLite migration defense-in-depth (DEFAULT + idempotent backfill)
- No archival needed (no entries >30d old in decisions.md)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Orchestrated multi-agent session for new generic data import feature architecture:

- Zoe (Lead): Full MVP architecture covering UX flows, content detection (heuristic-first,
  AI fallback), data model (no new tables), parsing pipeline, AI integration, service layer,
  scope phasing. Placement revision: separate `/import-content` page (not tab on existing
  `/import`), per Captain directive.

- Wash (Data Layer Scout): Surveyed existing YouTube pipeline pattern, found file import
  UI/service gap, confirmed no schema changes needed, identified dedup inconsistency for
  standardization.

- River (AI Strategy): Designed 5 AI prompt tasks with confidence thresholds, heuristic
  fallbacks, structured DTOs via `SendPrompt<T>`, permissive grading principles.

- Kaylee (UI Scout): Documented form patterns, file picker abstractions, resource lookup
  UI, navigation placement. Recommendations for ContentImportService, InputFile, preview
  table reuse.

- Copilot Directive: Confirmed scope separation — Video Subscriptions (existing) separate
  from generic content import (new) to keep features focused and growth paths independent.

Artifacts:
- 5 orchestration logs (one per agent) in .squad/orchestration-log/
- Session log in .squad/log/2026-04-24T22:31-data-import-architecture-plan.md
- 6 decisions merged into .squad/decisions.md (168KB total)
- All agent histories updated with import-plan context

Next: Implementation team begins ContentImportService + ImportContent.razor page. River
engineers 3 prompt templates (Format Inference, Content Classification, Extraction).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Captain resolved 7 open questions from architecture proposal:

1. Dedup default: Skip and reuse existing (safest, matches YouTube pipeline)
2. Source attribution: Deferred to v2
3. Single-column imports: Use AI to translate on import (new mvp-single-column-translate work item)
4. Mobile clipboard paste: Not needed for MVP
5. Replace-all mode: Deferred to v2
6. Renamed YouTube page: 'Media Import' at /media-import (not 'Video Subscriptions')
7. Separate-page placement: Confirmed — /import-content independent from /media-import

Updated decisions.md with final rulings appended and prior superseded mentions annotated.
All prior architecture content preserved; only updated with Captain's decisions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace empty catch blocks in StartImport, RetryImport (ImportEndpoints)
and TriggerCheck (ChannelEndpoints) with proper error handling:
- Log the exception via ILoggerFactory (Error level)
- Call FailImportAsync to mark the import as Failed with the error message

Make VideoImportPipelineService.FailImportAsync public so endpoints can
call it directly without needing a separate repository reference.

Previously, exceptions thrown before internal pipeline logging (DI
resolution failures, scope creation errors, first pipeline step) were
silently swallowed, leaving the import permanently stuck in Pending.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant