Skip to content

fix: inject project.slug from map key to prevent undefined slug in dispatch#2

Open
UBIpromoter wants to merge 1 commit intomainfrom
fix/12-slug-injection
Open

fix: inject project.slug from map key to prevent undefined slug in dispatch#2
UBIpromoter wants to merge 1 commit intomainfrom
fix/12-slug-injection

Conversation

@UBIpromoter
Copy link
Copy Markdown
Owner

Problem

project.slug was undefined throughout the dispatch pipeline when projects.json used non-standard keys (e.g. channel:1483593453739839609). This caused:

  1. activateWorker() to fail: "Project not found for slug or channelId: undefined"
  2. Worker state never recorded after dispatch
  3. Repeated dispatch attempts (heartbeat kept re-dispatching the same issue)

Root cause: getProject() returned raw JSON objects without injecting the slug field from the map key. The isLegacySchema() migration check only detected purely numeric keys, missing channel:-prefixed keys.

Changes

  • io.ts: readProjects() injects slug from map key for every project missing it; getProject() defensively injects slug from resolved key
  • schema-migration.ts: isLegacySchema() detects channel:-prefixed keys; migrateLegacySchema() strips the prefix when extracting channelIds
  • projects.test.ts: Added 3 test suites (slug injection, getProject injection, legacy schema detection)

Test plan

  • All 24 tests pass (npx tsx --test lib/projects/projects.test.ts)
  • Type check clean (npx tsc --noEmit)

Addresses issue UBIpromoter/Workflow#12

…spatch pipeline (laurentenhoor#12)

Root cause: getProject() returned raw JSON objects without the slug field populated.
When projects.json used non-standard keys (e.g. channel:<id>), project.slug was undefined,
causing activateWorker() to fail with 'Project not found for slug or channelId: undefined'.
This broke worker state recording after dispatch, leading to repeated dispatch attempts.

Changes:
- readProjects(): inject slug from map key into every project missing it
- getProject(): defensively inject slug from resolved key
- isLegacySchema(): detect channel:-prefixed keys as legacy format
- migrateLegacySchema(): strip channel: prefix when extracting channelIds
- Added tests for slug injection and legacy schema detection
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