Skip to content

feat(subscription): dual read/write taxcode on subscription items - #4011

Merged
borbelyr-kong merged 9 commits into
mainfrom
feat/tax-codes-double-read-write-subscription
Mar 27, 2026
Merged

borbelyr-kong merged 9 commits into
mainfrom
feat/tax-codes-double-read-write-subscription

Conversation

@borbelyr-kong

@borbelyr-kong borbelyr-kong commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Tax codes are now automatically resolved and associated with subscription items from Stripe tax metadata; tax configuration is persisted and surfaced on item views.
  • Refactor
    • Improved internal tax config backfill and catalog mapping to unify normalized and legacy tax fields.
  • Tests
    • Added end-to-end tests covering tax code resolution and DB round-trip persistence.

@coderabbitai

coderabbitai Bot commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 91859b16-f08c-4841-9275-58a56a5ce62f

📥 Commits

Reviewing files that changed from the base of the PR and between cb28743 and 449a50a.

📒 Files selected for processing (1)
  • openmeter/subscription/testutils/compare.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • openmeter/subscription/testutils/compare.go

📝 Walkthrough

Walkthrough

This PR wires a taxcode.Service into subscription services, moves BackfillTaxConfig into productcatalog, eagerly loads and persists TaxCode on subscription items, adds tax-code resolution during item creation, and adds tests and test helpers for tax-code behavior.

Changes

Cohort / File(s) Summary
Dependency Injection & Wiring
app/common/subscription.go, cmd/billing-worker/wire_gen.go, cmd/jobs/internal/wire_gen.go, cmd/server/wire_gen.go
Added taxCodeService parameter to NewSubscriptionServices and updated all Wire-generated calls to pass it through.
Productcatalog Backfill & Callers
openmeter/productcatalog/tax.go, openmeter/productcatalog/adapter/taxconfig.go, openmeter/productcatalog/addon/adapter/mapping.go, openmeter/productcatalog/plan/adapter/mapping.go
Moved BackfillTaxConfig into productcatalog and updated callers to use productcatalog.BackfillTaxConfig.
Subscription Service Config
openmeter/subscription/service/service.go, openmeter/subscription/testutils/service.go
Added TaxCode taxcode.Service to ServiceConfig and propagated it into test utilities.
Subscription Repo & Mapping
openmeter/subscription/repo/subscriptionitemrepo.go, openmeter/subscription/repo/mapping.go
Eager-load TaxCode via .WithTaxCode(), persist TaxCodeID and TaxBehavior on Create, map TaxCode edge into item meta and call BackfillTaxConfig.
Tax Code Resolution Logic
openmeter/subscription/service/synchelpers.go
Added resolveTaxCode to resolve/create TaxCode entities from RateCard metadata and set RateCard.TaxConfig.TaxCodeID, returning errors on failure.
Tests & Validation Utilities
openmeter/subscription/service/service_test.go, openmeter/subscription/testutils/compare.go
Added tests covering tax-code resolution and DB round-trips; added validation in comparisons to assert TaxCodeID/backfill behavior.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Service as SubscriptionService
    participant TaxSvc as TaxCodeService
    participant Repo as ItemRepository
    participant DB as Database

    Client->>Service: CreateSubscriptionItem(RateCard with Stripe code)
    activate Service
    Service->>Service: resolveTaxCode()
    Service->>TaxSvc: GetOrCreateByAppMapping(stripe_code)
    activate TaxSvc
    TaxSvc->>DB: Query/Create TaxCode
    DB-->>TaxSvc: TaxCode(entity with ID)
    TaxSvc-->>Service: TaxCode(entity)
    deactivate TaxSvc
    Service->>Service: Update RateCard.TaxConfig.TaxCodeID
    Service->>Repo: Create(item with TaxCodeID & TaxBehavior)
    activate Repo
    Repo->>DB: Persist subscription_item (+tax fields)
    DB-->>Repo: Success
    Repo-->>Service: Created item
    Service->>Repo: GetByID (WithTaxCode)
    Repo->>DB: Query item + TaxCode edge
    DB-->>Repo: Item + TaxCode entity
    Repo->>Repo: BackfillTaxConfig(TaxConfig, TaxBehavior, TaxCode)
    Repo-->>Service: Hydrated SubscriptionItem
    Service-->>Client: SubscriptionItem (TaxCodeID populated)
    deactivate Service
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

release-note/feature, area/subscriptions

Suggested reviewers

  • GAlexIHU
  • turip
  • tothandras
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.71% 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 title accurately describes the main change: adding dual read/write support for tax codes on subscription items across the codebase.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/tax-codes-double-read-write-subscription

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.

@borbelyr-kong borbelyr-kong added the release-note/ignore Ignore this change when generating release notes label Mar 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
openmeter/subscription/service/synchelpers.go (1)

119-121: Consider memoizing Stripe tax-code resolution per create flow.

Line 119 triggers resolution per item, and Lines 198-202 can hit the DB repeatedly for the same Stripe code. A small in-request cache keyed by Stripe code would keep behavior the same and cut extra round-trips.

As per coding guidelines **/*.go: “Performance should be a priority in critical code paths... database operations ... should be vetted for potential performance bottlenecks.”

Also applies to: 198-202


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: be4b0734-9840-4916-ac99-2b37f1911ec4

📥 Commits

Reviewing files that changed from the base of the PR and between a8b4bd5 and 4c68597.

📒 Files selected for processing (14)
  • app/common/subscription.go
  • cmd/billing-worker/wire_gen.go
  • cmd/jobs/internal/wire_gen.go
  • cmd/server/wire_gen.go
  • openmeter/productcatalog/adapter/taxconfig.go
  • openmeter/productcatalog/addon/adapter/mapping.go
  • openmeter/productcatalog/plan/adapter/mapping.go
  • openmeter/productcatalog/tax.go
  • openmeter/subscription/repo/mapping.go
  • openmeter/subscription/repo/subscriptionitemrepo.go
  • openmeter/subscription/service/service.go
  • openmeter/subscription/service/service_test.go
  • openmeter/subscription/service/synchelpers.go
  • openmeter/subscription/testutils/service.go
💤 Files with no reviewable changes (1)
  • openmeter/productcatalog/adapter/taxconfig.go

@borbelyr-kong
borbelyr-kong marked this pull request as ready for review March 26, 2026 13:34
@borbelyr-kong
borbelyr-kong requested a review from a team as a code owner March 26, 2026 13:34
@coderabbitai

coderabbitai Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":500,"request":{"method":"PATCH","url":"https://api.github.com/repos/openmeterio/openmeter/issues/comments/4133982333","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.6 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- walkthrough_start -->\n\n<details>\n<summary>📝 Walkthrough</summary>\n\n## Walkthrough\n\nThis PR integrates a `taxCodeService` dependency throughout the subscription system, enabling tax code resolution and backfilling. It moves tax config logic from the adapter layer to the core productcatalog, updates subscription repos to eagerly load and persist tax code entities, and adds service-level tax code resolution during subscription item creation.\n\n## Changes\n\n|Cohort / File(s)|Summary|\n|---|---|\n|**Dependency Wiring** <br> `app/common/subscription.go`, `cmd/billing-worker/wire_gen.go`, `cmd/jobs/internal/wire_gen.go`, `cmd/server/wire_gen.go`, `openmeter/subscription/testutils/service.go`|Added `taxCodeService` parameter to `NewSubscriptionServices` constructor and threaded it through all Wire-generated dependency injection calls.|\n|**Service Configuration** <br> `openmeter/subscription/service/service.go`|Extended `ServiceConfig` struct with new `TaxCode taxcode.Service` field to support tax code operations within the subscription service.|\n|**Tax Config Logic Migration** <br> `openmeter/productcatalog/adapter/taxconfig.go`, `openmeter/productcatalog/tax.go`, `openmeter/productcatalog/addon/adapter/mapping.go`, `openmeter/productcatalog/plan/adapter/mapping.go`|Moved `BackfillTaxConfig` function from adapter package to core `productcatalog` package; updated adapter callers to reference the new location.|\n|**Subscription Repository** <br> `openmeter/subscription/repo/subscriptionitemrepo.go`, `openmeter/subscription/repo/mapping.go`|Added eager loading of `TaxCode` edge in read queries and persistence of `TaxCodeID` and tax behavior fields during item creation; enhanced mapping to resolve and backfill tax code metadata.|\n|**Subscription Service Tax Resolution** <br> `openmeter/subscription/service/synchelpers.go`|Introduced `resolveTaxCode` helper method to resolve Stripe tax codes to `TaxCode` entities and update rate card metadata during item creation.|\n|**Tests & Validation** <br> `openmeter/subscription/service/service_test.go`, `openmeter/subscription/testutils/compare.go`|Added two new test cases validating tax code resolution and round-trip persistence; enhanced `ValidateSpecAndView` to assert `TaxCodeID` consistency when Stripe codes are present.|\n\n## Sequence Diagram(s)\n\n```mermaid\nsequenceDiagram\n    participant SubSvc as Subscription Service\n    participant TaxSvc as Tax Code Service\n    participant ItemRepo as Item Repository\n    participant DB as Database\n    \n    SubSvc->>SubSvc: Create subscription item<br/>(with RateCard.TaxConfig.Stripe.Code)\n    SubSvc->>SubSvc: resolveTaxCode(rateCard)\n    SubSvc->>TaxSvc: GetOrCreateByAppMapping<br/>(Stripe app, taxCode)\n    TaxSvc->>DB: Lookup/Create TaxCode entity\n    DB-->>TaxSvc: TaxCode ID\n    TaxSvc-->>SubSvc: TaxCode entity\n    SubSvc->>SubSvc: Update RateCard.TaxConfig.TaxCodeID\n    SubSvc->>ItemRepo: Create item with updated metadata\n    ItemRepo->>DB: Persist TaxCodeID + TaxConfig\n    DB-->>ItemRepo: Success\n    ItemRepo-->>SubSvc: Item created\n```\n\n## Estimated code review effort\n\n🎯 3 (Moderate) | ⏱️ ~22 minutes\n\n## Possibly related PRs\n\n- **PR `#3892`**: Implements the `taxcode.Service` and core tax code functionality that this PR depends on and integrates.\n- **PR `#3941`**: Adds schema-level tax code support (ent edges and migrations) that complements the service-level changes here.\n- **PR `#3899`**: Related wiring changes for injecting `taxCodeService` into application constructors at the infrastructure level.\n\n## Suggested labels\n\n`release-note/feature`, `area/subscriptions`\n\n## Suggested reviewers\n\n- GAlexIHU\n- turip\n- tothandras\n\n</details>\n\n<!-- walkthrough_end -->\n\n\n<!-- pre_merge_checks_walkthrough_start -->\n\n<details>\n<summary>🚥 Pre-merge checks | ✅ 2 | ❌ 1</summary>\n\n### ❌ Failed checks (1 warning)\n\n|     Check name     | Status     | Explanation                                                                           | Resolution                                                                         |\n| :----------------: | :--------- | :------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- |\n| Docstring Coverage | ⚠️ Warning | Docstring coverage is 35.71% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |\n\n<details>\n<summary>✅ Passed checks (2 passed)</summary>\n\n|     Check name    | Status   | Explanation                                                                                                                  |\n| :---------------: | :------- | :--------------------------------------------------------------------------------------------------------------------------- |\n| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled.                                                                  |\n|    Title check    | ✅ Passed | The title clearly describes the main change: implementing dual read/write functionality for tax codes on subscription items. |\n\n</details>\n\n<sub>✏️ Tip: You can configure your own custom pre-merge checks in the settings.</sub>\n\n</details>\n\n<!-- pre_merge_checks_walkthrough_end -->\n\n<!-- finishing_touch_checkbox_start -->\n\n<details>\n<summary>✨ Finishing Touches</summary>\n\n<details>\n<summary>📝 Generate docstrings</summary>\n\n- [ ] <!-- {\"checkboxId\": \"7962f53c-55bc-4827-bfbf-6a18da830691\"} --> Create stacked PR\n- [ ] <!-- {\"checkboxId\": \"3e1879ae-f29b-4d0d-8e06-d12b7ba33d98\"} --> Commit on current branch\n\n</details>\n<details>\n<summary>🧪 Generate unit tests (beta)</summary>\n\n- [ ] <!-- {\"checkboxId\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Create PR with unit tests\n- [ ] <!-- {\"checkboxId\": \"6ba7b810-9dad-11d1-80b4-00c04fd430c8\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Commit unit tests in branch `feat/tax-codes-double-read-write-subscription`\n\n</details>\n\n</details>\n\n<!-- finishing_touch_checkbox_end -->\n\n<!-- tips_start -->\n\n---\n\nThanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=openmeterio/openmeter&utm_content=4011)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n<details>\n<summary>❤️ Share</summary>\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n</details>\n\n<sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub>\n\n<!-- tips_end -->\n\n<!-- internal state start -->\n\n\n<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEejqANiS4AzEtQAUibAMQMK8buPwYAlF1psNAtICntaAHoAdw8aSFw0AA8mJX4sZ1d3T28sdRJmRAMAOWxmAUouABYABgBGWoMAVQAlABkuWFxcbkQOCIiidVgXDSZmCPxuMjYaD3wJqYwZygjubAsLCJr6psQKyAF8CnKLWQowAGsfIgMAZXxsCgYSA6oMBlhbe1wIhMSwFLSMC0B4CKxgMJoWhgGJ5MAZNweLzwHwGaBoCikXCvTAfLjMbQYO4JXDYXr8RYGZokCTwEhRSjkgDiAEErIkAJIACUaBlaKhIFnJYSsaD2YAw+BoEXgRElYQMAGFITR6NQuAAmaoagBsYGqAGYwLroPUOJUAJwcDUGgBaRn0xnAUDI9HwNhwBGIZGUqoUrHYXF4/GEonEUhk8kBVFU6i0OkdJigcFQqEwnsIpHIVD9YzYGE4oTQUUgzlYGPkcgUShjak02l0YEMTtMBjQ3G4ETzPgiCKyyJ8GiI+A4BgARBODABiKeQFkc73Z6h0UulAkUeTuxiwTCkQpQACiiRoGCU9FwsBeAAMivTbi5EdkURhbpRac9EFeFBhELgKNgxCOeJ8HQBhni8dAsChWh1GfYJICURYlHeeRuAxNBlj4K8/kVRQSFfCh3xeP5AQ0AiiKvDQDCgAAFMU9nPBBkHIEtsK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jwGTOCAUznpeMszFYGHgWTnRjMzkY9M9lokFJy4yAJaOUCkBbZ6Y76TzLWmqjdJAMzAEDLxmhzo0CgK0ZikgAGhsmGgaEQAFIpce5V9ComwDfRuIdIAsJBVUFhBGIFFC9EzFfRHDqgGgaoNUHzmmyCJ73IWXjLyl5AEIyUwhqB38GTikcSAINp5FnQpQCM4gRADYHkDDQmAmc9SPXPYSYyCJFsvGVbKJkETSZlHCwB7Kpl4zTRik32WlL5IABdI6WKFlHNB2ZB0i0ByiOF/D/h+ImwLiINAYidQtQZ+ZUGyYGgzhJABEdkx1A2BIRFoK4bzQtAkjsmtAHUGcJRF1ANQDAB4RqGya1A0AFoWoOUAgUahagw8ZMZ0PDysjKApAHuIHLWGMiOhCw3oQQB7hoR6UWwkkH0h5EgiDAfIscMdNlG9CGIkDakEajoDSilhuEfaLgCVHVBCFoIiABmHoU8KWFzCnuFQr0BAA -->\n\n<!-- internal state end -->"},"request":{"retryCount":3,"retries":3,"retryAfter":16}}}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openmeter/subscription/testutils/compare.go`:
- Around line 85-93: The test may panic because foundMeta.TaxConfig can be nil
while specMeta has a Stripe code; before accessing foundMeta.TaxConfig.TaxCodeID
in the block that checks specMeta.TaxConfig.Stripe.Code, first require that
foundMeta.TaxConfig is not nil (e.g., require.NotNil(t, foundMeta.TaxConfig,
"...", specItem.ItemKey, specPhase.PhaseKey)) and only then require/ assert on
foundMeta.TaxConfig.TaxCodeID and equality with specMeta.TaxConfig.TaxCodeID;
keep the existing else branch that asserts foundMeta.TaxConfig == nil for items
without a Stripe tax code.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a43f7c6b-11ed-4758-94e4-57a17fb94915

📥 Commits

Reviewing files that changed from the base of the PR and between 4c68597 and 28ec714.

📒 Files selected for processing (1)
  • openmeter/subscription/testutils/compare.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openmeter/subscription/testutils/compare.go`:
- Around line 88-93: The current conditional in compare.go checks TaxCodeID
equality only when specMeta.TaxConfig.Stripe.Code is present, which is incorrect
because TaxCodeID may be backfilled independently; change the logic to first
branch on whether specMeta.TaxConfig.TaxCodeID is set: if
specMeta.TaxConfig.TaxCodeID != "" then require foundMeta.TaxConfig and assert
equality between specMeta.TaxConfig.TaxCodeID and foundMeta.TaxConfig.TaxCodeID;
else if specMeta.TaxConfig != nil && specMeta.TaxConfig.Stripe != nil &&
specMeta.TaxConfig.Stripe.Code != "" then require foundMeta.TaxConfig and
require foundMeta.TaxConfig.TaxCodeID to be non-nil (backfilled) but do not
assert equality to the Stripe code; otherwise assert
foundMeta.TaxConfig.TaxCodeID is nil. Use the existing symbols
specMeta.TaxConfig, specMeta.TaxConfig.Stripe.Code, specMeta.TaxConfig.TaxCodeID
and foundMeta.TaxConfig.TaxCodeID to locate and update the branches.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f9509cb8-b7e9-4f92-a6e1-25f69af27f40

📥 Commits

Reviewing files that changed from the base of the PR and between 4c68597 and cb28743.

📒 Files selected for processing (1)
  • openmeter/subscription/testutils/compare.go

@GAlexIHU GAlexIHU left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

good work!

@borbelyr-kong
borbelyr-kong merged commit 789e8e1 into main Mar 27, 2026
23 checks passed
@borbelyr-kong
borbelyr-kong deleted the feat/tax-codes-double-read-write-subscription branch March 27, 2026 12:32

This branch was previously deployed

1 inactive deployment
dev — 449a50ad Deployed Mar 27, 2026 by borbelyr-kong via Migration Checks #12919
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/ignore Ignore this change when generating release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants