Skip to content

Conversation

@worldInColors
Copy link
Contributor

@worldInColors worldInColors commented Jan 4, 2026

Summary by CodeRabbit

  • Chores
    • Improved template loading process to automatically migrate template configurations, ensuring better compatibility across versions.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 4, 2026

Walkthrough

A migration function is now applied to template configuration objects prior to schema validation during JSON template loading, ensuring config compatibility before parsing.

Changes

Cohort / File(s) Summary
Template Migration
packages/core/src/utils/templates.ts
Added import of applyMigrations from './config.js'; config migration is now applied to rawTemplate.config before TemplateSchema.parse validation

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A tiny hop, a migration applied,
Before the schema's scrutiny far and wide,
Config freshened, compatibility blessed,
Templates now pass their validation test!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: applying migrations before parsing config in the templates utility.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de956de and a867c5b.

📒 Files selected for processing (1)
  • packages/core/src/utils/templates.ts
🧰 Additional context used
🧬 Code graph analysis (1)
packages/core/src/utils/templates.ts (1)
packages/core/src/db/schemas.ts (1)
  • TemplateSchema (1126-1152)
🔇 Additional comments (2)
packages/core/src/utils/templates.ts (2)

7-7: LGTM! Clean import addition.

The addition of applyMigrations to the import statement is clean and necessary for the migration logic introduced below.


87-92: Code is sound—applyMigrations is defensive and idempotent.

The migration logic is correctly positioned before schema validation. Verification confirms:

  • Error handling: applyMigrations uses purely defensive transformations with conditional checks (typeof, Array.isArray, optional chaining) and does not throw. Unmatched conditions are silently skipped, making it safe to call on any input.
  • Idempotency: Each migration checks for the old format before applying (e.g., deduplicator.multiGroupBehaviour checks typeof === 'string', which fails after migration to enum). Once migrated, re-running produces no additional changes.
  • Conditional check: The check on line 89 (if (rawTemplate.config)) is good defensive programming for malformed templates.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Viren070 Viren070 merged commit 21fec28 into Viren070:main Jan 5, 2026
3 checks passed
@Viren070 Viren070 mentioned this pull request Jan 5, 2026
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.

2 participants