Skip to content

feat: add branching support to resolvable import endpoints#3532

Open
dkrizan wants to merge 1 commit intomainfrom
dkrizan/import-resolvable-branching
Open

feat: add branching support to resolvable import endpoints#3532
dkrizan wants to merge 1 commit intomainfrom
dkrizan/import-resolvable-branching

Conversation

@dkrizan
Copy link
Contributor

@dkrizan dkrizan commented Mar 13, 2026

Summary

  • Add branch query parameter to POST /keys/import-resolvable (deprecated endpoint used by Figma plugin)
  • Add branch field to POST /single-step-import-resolvable request body (newer replacement endpoint)
  • Both endpoints now support importing keys to a specific branch, with feature guard validation
  • ResolvingKeyImporter now filters existing keys by branch, preventing cross-branch key collisions

Test plan

  • KeyControllerBranchingTest — import-resolvable imports keys to specified branch
  • KeyControllerBranchingTest — import-resolvable fails when branching feature not enabled
  • SingleStepImportResolvableBranchingTest — imports keys to specified branch
  • SingleStepImportResolvableBranchingTest — imports to default branch when no branch specified
  • SingleStepImportResolvableBranchingTest — keys on branch not visible on default branch
  • SingleStepImportResolvableBranchingTest — fails when feature not enabled
  • SingleStepImportResolvableBranchingTest — succeeds without branch when feature not enabled

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Key import endpoints now accept an optional branch parameter, enabling users to import keys directly into a specified branch when the BRANCHING feature is enabled. Keys will be imported to the default branch if no branch is specified. This applies to both standard and resolvable import workflows.
  • Tests

    • Added comprehensive test coverage for importing keys to specific branches. Tests validate proper feature flag enforcement and ensure keys imported to a specific branch are isolated from other branches as expected.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
API Controllers
backend/api/src/main/kotlin/io/tolgee/api/v2/controllers/dataImport/SingleStepImportController.kt, backend/api/src/main/kotlin/io/tolgee/api/v2/controllers/keys/KeyController.kt
Added optional branch request parameters to import endpoints with BRANCHING feature guards; parameters are validated before service delegation.
Request DTOs
backend/data/src/main/kotlin/io/tolgee/dtos/request/importKeysResolvable/SingleStepImportResolvableRequest.kt
Added optional branch field to request data class with Swagger documentation, enabling clients to specify target branch for imports.
Service Layer
backend/data/src/main/kotlin/io/tolgee/service/dataImport/SingleStepImportService.kt, backend/data/src/main/kotlin/io/tolgee/service/key/KeyService.kt
Threaded branch parameter through service methods to prepare for downstream resolution logic.
Import Resolution Logic
backend/data/src/main/kotlin/io/tolgee/service/key/ResolvingKeyImporter.kt
Implemented branch-aware key filtering in queries using branch predicates; when a branch is specified, keys are filtered by branch; otherwise, defaults are applied; branch is used during key creation.
Branching Tests
ee/backend/tests/src/test/kotlin/io/tolgee/ee/api/v2/controllers/branching/KeyControllerBranchingTest.kt, ee/backend/tests/src/test/kotlin/io/tolgee/ee/api/v2/controllers/branching/SingleStepImportResolvableBranchingTest.kt
Added test coverage for import-resolvable and single-step import flows with branch parameters, including feature flag validation and branch isolation verification.
Generated API Schema
webapp/src/service/apiSchema.generated.ts
Updated OpenAPI schema to reflect new branch query parameters in import operations.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • bdshadow
  • JanCizmar

🐰 Hopping through branches, keys now find their way,
To the right Git home, come what may,
Guards check the feature, filters sort it neat,
Branch-aware imports—now that's pretty sweet! 🌿✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: add branching support to resolvable import endpoints' accurately summarizes the main changes across all modified files, which focus on adding branch parameter support to import-resolvable endpoints with feature guards.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dkrizan/import-resolvable-branching
📝 Coding Plan
  • Generate coding plan for human review comments

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.

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>
@dkrizan dkrizan force-pushed the dkrizan/import-resolvable-branching branch from 2bc6752 to dc06c26 Compare March 13, 2026 18:54
@dkrizan dkrizan marked this pull request as ready for review March 13, 2026 18:55
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 75bef41 and dc06c26.

📒 Files selected for processing (9)
  • backend/api/src/main/kotlin/io/tolgee/api/v2/controllers/dataImport/SingleStepImportController.kt
  • backend/api/src/main/kotlin/io/tolgee/api/v2/controllers/keys/KeyController.kt
  • backend/data/src/main/kotlin/io/tolgee/dtos/request/importKeysResolvable/SingleStepImportResolvableRequest.kt
  • backend/data/src/main/kotlin/io/tolgee/service/dataImport/SingleStepImportService.kt
  • backend/data/src/main/kotlin/io/tolgee/service/key/KeyService.kt
  • backend/data/src/main/kotlin/io/tolgee/service/key/ResolvingKeyImporter.kt
  • ee/backend/tests/src/test/kotlin/io/tolgee/ee/api/v2/controllers/branching/KeyControllerBranchingTest.kt
  • ee/backend/tests/src/test/kotlin/io/tolgee/ee/api/v2/controllers/branching/SingleStepImportResolvableBranchingTest.kt
  • webapp/src/service/apiSchema.generated.ts

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.

1 participant