feat: add branching support to resolvable import endpoints#3532
feat: add branching support to resolvable import endpoints#3532
Conversation
📝 WalkthroughWalkthroughThis PR adds branch-aware import functionality for keys across the API and service layers. Optional branch parameters are introduced to import endpoints with feature guards, propagated through service layers, and applied as filtering logic in key resolution queries. Changes
Sequence Diagram(s)sequenceDiagram
actor Client
participant KeyController
participant ProjectFeatureGuard
participant KeyService
participant ResolvingKeyImporter
participant Database
Client->>KeyController: POST /keys/import-resolvable<br/>(branch="dev")
KeyController->>ProjectFeatureGuard: checkIfUsed(BRANCHING, "dev")
alt Feature Disabled
ProjectFeatureGuard-->>Client: FEATURE_NOT_ENABLED Error
else Feature Enabled
ProjectFeatureGuard-->>KeyController: OK
KeyController->>KeyService: importKeysResolvable(keys,<br/>project, branch="dev")
KeyService->>ResolvingKeyImporter: new(..., branch="dev")
ResolvingKeyImporter->>Database: Fetch keys by namespace/name<br/>filtered to branch="dev"
Database-->>ResolvingKeyImporter: keys on dev branch
ResolvingKeyImporter->>ResolvingKeyImporter: Resolve conflicts/<br/>create keys on dev branch
ResolvingKeyImporter->>Database: Persist/update keys<br/>on dev branch
Database-->>ResolvingKeyImporter: Success
ResolvingKeyImporter-->>KeyService: KeyImportResolvableResult
KeyService-->>KeyController: Result
KeyController-->>Client: Import result
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
Add branch parameter to both import-resolvable and single-step-import-resolvable endpoints, enabling Figma plugin and other API consumers to import keys to specific branches. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2bc6752 to
dc06c26
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ee/backend/tests/src/test/kotlin/io/tolgee/ee/api/v2/controllers/branching/SingleStepImportResolvableBranchingTest.kt (1)
68-100: Consider enabling the BRANCHING feature flag for consistency and clarity.This test verifies that imports default to the "main" branch when no branch is specified. However, unlike the other tests in this file, it doesn't explicitly set
enabledFeaturesProvider.forceEnabled. While the test passes because the null branch skips the feature guard check, this behavior is implicit rather than explicit.For test clarity and to better document the expected behavior, consider explicitly enabling the feature:
♻️ Suggested change
`@Test` `@ProjectJWTAuthTestMethod` fun `imports to default branch when no branch specified`() { + enabledFeaturesProvider.forceEnabled = setOf(Feature.BRANCHING) performProjectAuthPost( "single-step-import-resolvable",🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ee/backend/tests/src/test/kotlin/io/tolgee/ee/api/v2/controllers/branching/SingleStepImportResolvableBranchingTest.kt` around lines 68 - 100, The test `imports to default branch when no branch specified` in SingleStepImportResolvableBranchingTest should explicitly enable the BRANCHING feature for clarity: before calling performProjectAuthPost set enabledFeaturesProvider.forceEnabled to include Feature.BRANCHING (or the equivalent feature constant used elsewhere in this test class) so the test environment matches other tests and documents the expected feature flag state.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@ee/backend/tests/src/test/kotlin/io/tolgee/ee/api/v2/controllers/branching/SingleStepImportResolvableBranchingTest.kt`:
- Around line 68-100: The test `imports to default branch when no branch
specified` in SingleStepImportResolvableBranchingTest should explicitly enable
the BRANCHING feature for clarity: before calling performProjectAuthPost set
enabledFeaturesProvider.forceEnabled to include Feature.BRANCHING (or the
equivalent feature constant used elsewhere in this test class) so the test
environment matches other tests and documents the expected feature flag state.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b443a947-e8bd-428a-be59-ed5f64919ea8
📒 Files selected for processing (9)
backend/api/src/main/kotlin/io/tolgee/api/v2/controllers/dataImport/SingleStepImportController.ktbackend/api/src/main/kotlin/io/tolgee/api/v2/controllers/keys/KeyController.ktbackend/data/src/main/kotlin/io/tolgee/dtos/request/importKeysResolvable/SingleStepImportResolvableRequest.ktbackend/data/src/main/kotlin/io/tolgee/service/dataImport/SingleStepImportService.ktbackend/data/src/main/kotlin/io/tolgee/service/key/KeyService.ktbackend/data/src/main/kotlin/io/tolgee/service/key/ResolvingKeyImporter.ktee/backend/tests/src/test/kotlin/io/tolgee/ee/api/v2/controllers/branching/KeyControllerBranchingTest.ktee/backend/tests/src/test/kotlin/io/tolgee/ee/api/v2/controllers/branching/SingleStepImportResolvableBranchingTest.ktwebapp/src/service/apiSchema.generated.ts
Summary
branchquery parameter toPOST /keys/import-resolvable(deprecated endpoint used by Figma plugin)branchfield toPOST /single-step-import-resolvablerequest body (newer replacement endpoint)ResolvingKeyImporternow filters existing keys by branch, preventing cross-branch key collisionsTest plan
KeyControllerBranchingTest— import-resolvable imports keys to specified branchKeyControllerBranchingTest— import-resolvable fails when branching feature not enabledSingleStepImportResolvableBranchingTest— imports keys to specified branchSingleStepImportResolvableBranchingTest— imports to default branch when no branch specifiedSingleStepImportResolvableBranchingTest— keys on branch not visible on default branchSingleStepImportResolvableBranchingTest— fails when feature not enabledSingleStepImportResolvableBranchingTest— succeeds without branch when feature not enabled🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests