Repository navigation
Fix codemode job metadata mutations - #571
Conversation
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughJob source lookups now use user-scoped entity-source queries. Job updates only sync source snapshots for selected field changes, and the codemode registry test adds production-shaped update and delete coverage. ChangesJob mutation flow
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🔎 Preview deployed: https://kody-pr-571.kentcdodds.workers.dev Worker: Mocks:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/worker/src/jobs/service.ts`:
- Around line 925-931: The sync guard in shouldSyncJobSourceForUpdate misses
source-shape updates, so changes to sourceId or publishedCommit can bypass
syncing and leave updated with an unverified source pointer. Update
shouldSyncJobSourceForUpdate in service.ts to treat sourceId and publishedCommit
as sync-triggering fields, and make resolveUpdatedShape consistent by either
including those fields in the decision or rejecting/ignoring them before
constructing updated. Apply the same fix anywhere the update flow relies on this
predicate so source-related updates always force the matching snapshot to be
published.
In `@packages/worker/src/mcp/run-codemode-registry.node.test.ts`:
- Around line 253-257: The mock and test are allowing unscoped entity_sources
reads, which can hide cross-user access bugs. Update the D1 mock in
run-codemode-registry.node.test.ts to require userId scoping for entity_sources
lookups instead of accepting SELECT * FROM entity_sources WHERE id = ?, and
adjust the assertions around the delete/read flow to include user_id in the
lookup. Use the existing entity_sources select path and the related test case
that performs the post-delete read to ensure every read/write stays user-scoped.
- Around line 523-535: The JOB_MANAGER mock is too permissive and doesn’t verify
user-scoped routing, so this regression test can miss non-namespaced Durable
Object access. Tighten the mock in run-codemode-registry.node.test.ts by
asserting that idFromName receives a userId-prefixed name and that the syncAlarm
call is made with the expected userId. Use the JOB_MANAGER idFromName and
get().syncAlarm hooks to enforce the namespace contract so the test fails if
routing is not user-scoped.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: ff40c5c2-a3a2-4846-8081-bc13cbf72212
📒 Files selected for processing (3)
packages/worker/src/jobs/service.node.test.tspackages/worker/src/jobs/service.tspackages/worker/src/mcp/run-codemode-registry.node.test.ts
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Summary
codemode.job_updateandcodemode.job_deletethrough the real capability registry/service path with a D1-shaped production-style env.Validation
npx vitest run packages/worker/src/jobs/service.node.test.ts packages/worker/src/mcp/run-codemode-registry.node.test.tsnpm run format:checknpm run typechecknpm run lint(warnings only)npm run validateRollout notes
codemode.job_update({ id: '504513c3-f29e-47f0-9ea1-402569ebef54', enabled: false })orcodemode.job_delete({ id: '504513c3-f29e-47f0-9ea1-402569ebef54' })to disable/delete the temporaryhrv-discord-reaction-pollerscheduled job.Summary by CodeRabbit