Resolve #2746: Validate explicit Cron distributed owner IDs#2758
Merged
Conversation
Cron normalizes user-provided distributed ownerId without validation, so invalid or empty owner IDs could enter Redis lock ownership state despite the distributed-lock contract. Trim and validate explicit ownerId during module option normalization, rejecting blank, empty, or non-string values before scheduler or Redis lifecycle setup. Closes #2746
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.
Summary
Cron normalized user-provided distributed
ownerIdwithout validation, so invalid or empty owner IDs could enter Redis lock ownership state despite the distributed-lock contract. This PR validates explicitdistributed.ownerIdat the module configuration boundary before scheduler or Redis lifecycle setup.Linked context: #2746
Changes
packages/cron/src/module.ts: AddnormalizeDistributedOwnerId(...)that trims an explicitownerIdand rejects blank, empty, or non-string values during module option normalization, before scheduler or Redis lifecycle setup. Mirrors the existingnormalizeRedisClientName(...)andassertValidDistributedLockTtlMs(...)boundary-validation pattern.packages/cron/src/module.test.ts: Add regression tests covering blank, empty, and non-string explicitownerIdrejection during normalization, before Redis probe I/O, and during bootstrap; plus trim and valid-ownerId preservation tests.packages/cron/README.mdandpackages/cron/README.ko.md: Document that fluo trims and validates explicitdistributed.ownerIdbefore scheduler or Redis lifecycle setup so invalid or empty owner identifiers cannot enter Redis lock ownership state..changeset/cron-validate-distributed-owner-ids.md: Patch changeset for@fluojs/cronbecause README documentsdistributed.ownerIdand this is a behavior change at the module configuration boundary.Testing
pnpm vitest run packages/cron— 92 tests passed (4 test files), including the new ownerId validation regression tests.pnpm build— succeeded.pnpm typecheck— succeeded.pnpm lint— exited 0; no new diagnostics in changed files.Release impact
Public export documentation
normalizeCronModuleOptionsalready documented; no new public export added.)@param/@returnstags where applicable.@exampleblocks and README scenario examples still play complementary roles.Behavioral contract
Platform consistency governance (SSOT)
Closes #2746