fix: inject project.slug from map key to prevent undefined slug in dispatch#2
Open
UBIpromoter wants to merge 1 commit intomainfrom
Open
fix: inject project.slug from map key to prevent undefined slug in dispatch#2UBIpromoter wants to merge 1 commit intomainfrom
UBIpromoter wants to merge 1 commit intomainfrom
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
project.slugwasundefinedthroughout the dispatch pipeline when projects.json used non-standard keys (e.g.channel:1483593453739839609). This caused:activateWorker()to fail: "Project not found for slug or channelId: undefined"Root cause:
getProject()returned raw JSON objects without injecting theslugfield from the map key. TheisLegacySchema()migration check only detected purely numeric keys, missingchannel:-prefixed keys.Changes
io.ts:readProjects()injects slug from map key for every project missing it;getProject()defensively injects slug from resolved keyschema-migration.ts:isLegacySchema()detectschannel:-prefixed keys;migrateLegacySchema()strips the prefix when extracting channelIdsprojects.test.ts: Added 3 test suites (slug injection, getProject injection, legacy schema detection)Test plan
npx tsx --test lib/projects/projects.test.ts)npx tsc --noEmit)Addresses issue UBIpromoter/Workflow#12