Skip to content

fix(api): correct mismatched inject array in ActivityPipelineService factory#13

Open
ironhardi wants to merge 1 commit into
openathleteorg:mainfrom
ironhardi:fix/activity-pipeline-processor-injection
Open

fix(api): correct mismatched inject array in ActivityPipelineService factory#13
ironhardi wants to merge 1 commit into
openathleteorg:mainfrom
ironhardi:fix/activity-pipeline-processor-injection

Conversation

@ironhardi

Copy link
Copy Markdown

Summary

  • The useFactory for ActivityPipelineService in apps/api/src/modules/core/core.module.ts had 5 entries in its inject array (PrismaService, GapProcessor, WeatherProcessor, NormalizationProcessor, TrainingMatchProcessor) but the factory function only accepts 4 parameters (gap, weather, normalization, trainingMatch).
  • NestJS resolves inject positionally, so every processor instance was shifted by one slot: gap actually received the PrismaService instance, weather received GapProcessor, normalization received WeatherProcessor, and trainingMatch received NormalizationProcessor. TrainingMatchProcessor was resolved but silently dropped entirely.
  • ActivityPipelineService.run() iterates over these (wrong) instances and calls .run(ctx) on each; none of them are actual ActivityProcessors, so every call threw processor.run is not a function. The error is caught and only logged, so this failed silently for every imported activity, across all providers (Strava, Garmin, Polar, Suunto) — not an isolated case.
  • Practical impact: weather enrichment, GAP (grade-adjusted pace), speed normalization, and automatic training/competition matching never ran for any activity.

Fix

Remove PrismaService from the inject array — it isn't an actual dependency of this factory, only the four processors are.

Test plan

  • Rebuilt the API and uploaded a test activity (GPX file) through the API
  • Confirmed via server logs that all four processors (GapProcessor, WeatherProcessor, NormalizationProcessor, TrainingMatchProcessor) now run successfully, where before all four failed with processor.run is not a function
  • Confirmed GET /event/:eventId/weather and GET /event/:eventId/normalization return populated data after the fix

…factory

The useFactory inject array had 5 entries (including PrismaService) but
the factory function only accepts 4 parameters (gap, weather,
normalization, trainingMatch). NestJS resolves inject positionally, so
every processor instance was shifted by one slot and TrainingMatchProcessor
was silently dropped entirely.

As a result, ActivityPipelineService.run() iterated over the wrong
instances (PrismaService, GapProcessor, WeatherProcessor,
NormalizationProcessor), none of which have a .run() method, so every
processor threw "processor.run is not a function" on every activity
import (all providers, not just one) and was silently swallowed by the
catch block. Weather enrichment, GAP pace, speed normalization, and
automatic training/competition matching never ran for any activity.

Removing PrismaService (not an actual dependency of this factory) from
the inject array restores the correct positional mapping.
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