enhancement-fix(spec): improve config semantic validation errors#2112
enhancement-fix(spec): improve config semantic validation errors#2112jaya6400 wants to merge 1 commit into
Conversation
- Add validateConfigSemantics() to check locales, empty/duplicate targets, and buckets. - Map v1/v1.1 bucket types to catch unknown IDs correctly. - Add schema min(1) defense to targets. - All 35 tests pass.
📝 WalkthroughWalkthroughThis PR enhances i18n configuration validation by introducing semantic validation logic that aggregates all validation errors and reports them with descriptive messages. The semantic validator runs after structural schema validation and in both standard and config-upgrade parse paths to catch missing source locales, empty or duplicate target locales, missing buckets, and unknown bucket types. ChangesConfiguration Validation Enhancement
🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/spec/src/config.ts (1)
217-217: 💤 Low valueConsider removing redundant semantic validation or validating the upgrade result.
This validates
rawConfigafter the upgrade completes, but the samerawConfigwas already validated at Line 213 before the upgrade. This is redundant. If the intent is to verify upgrade correctness, validateresultinstead:validateConfigSemantics(result). Otherwise, remove this line to reduce confusion.♻️ Options to resolve redundancy
Option 1: Remove redundant validation
const baseConfig = definition.parse(rawConfig); const result = upgrader(baseConfig); - validateConfigSemantics(rawConfig); return result;Option 2: Validate upgrade output
const baseConfig = definition.parse(rawConfig); const result = upgrader(baseConfig); - validateConfigSemantics(rawConfig); + validateConfigSemantics(result); return result;🤖 Prompt for 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. In `@packages/spec/src/config.ts` at line 217, The call to validateConfigSemantics after the upgrade is validating rawConfig again (redundant); change that invocation to validate the upgraded configuration by replacing validateConfigSemantics(rawConfig) with validateConfigSemantics(result) so the upgrade output is verified (reference: validateConfigSemantics, rawConfig, result).
🤖 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.
Nitpick comments:
In `@packages/spec/src/config.ts`:
- Line 217: The call to validateConfigSemantics after the upgrade is validating
rawConfig again (redundant); change that invocation to validate the upgraded
configuration by replacing validateConfigSemantics(rawConfig) with
validateConfigSemantics(result) so the upgrade output is verified (reference:
validateConfigSemantics, rawConfig, result).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3e283904-6b18-40af-be33-cb192039e20d
📒 Files selected for processing (3)
.changeset/improve-config-validation-errors.mdpackages/spec/src/config.spec.tspackages/spec/src/config.ts
|
Hi, could a maintainer please approve the pending workflows for this PR? Thanks! |
Added validateConfigSemantics() that runs on successful parse and before the upgrade fallback, with helpers for legacy-upgrade detection and unknown bucket ID resolution (v1 path→type vs v1.1+ type→config formats).
New error messages:
Also added .min(1) on localeSchema.targets as schema-level defense.
Tests: All 35 spec tests pass (pnpm --filter "@lingo.dev/_spec" test).
Testing
Visuals
Required for UI/UX changes:
Checklist
Closes #561
Summary by CodeRabbit