Skip to content

fix: prevent ensure-entitlement commands from overwriting existing org entitlement tier#2235

Closed
absarasw wants to merge 1 commit intomainfrom
update-ensure-entitlement-site-command
Closed

fix: prevent ensure-entitlement commands from overwriting existing org entitlement tier#2235
absarasw wants to merge 1 commit intomainfrom
update-ensure-entitlement-site-command

Conversation

@absarasw
Copy link
Copy Markdown
Contributor

@absarasw absarasw commented Apr 17, 2026

Replaced by adobe/spacecat-shared#1547

Summary

  • The ensure entitlement site and ensure entitlement imsorg Slack commands unconditionally called tierClient.createEntitlement('FREE_TRIAL'), which overwrites any existing non-PAID entitlement tier (e.g. PLG, PRE_ONBOARD) to FREE_TRIAL.
  • Both paths now check for an existing entitlement first via checkValidEntitlement(). If one exists, the current tier is preserved and only a site enrollment is created if missing. A new FREE_TRIAL entitlement is only created when none exists for the product on the org.
  • Slack messages now distinguish three outcomes: entitlement+enrollment already existed, enrollment created for existing entitlement, or both newly created.

Changes

  • src/support/slack/actions/entitlement-modal-utils.jscreateEntitlementsForProducts() checks for existing entitlement before creating; postEntitlementMessages() reports distinct outcomes
  • src/support/slack/actions/entitlement-modals.jsensureEntitlementImsOrgModal() checks for existing entitlement before creating
  • test/support/slack/actions/entitlement-modal-utils.test.js — updated and added tests for all three entitlement result paths
  • test/support/slack/actions/entitlement-modals.test.js — added test for "existing entitlement preserved" path; 100% coverage

Test plan

  • Run ensure entitlement site <url> on a site whose org has a PLG entitlement — verify tier stays PLG, enrollment is created if missing, Slack message says "already exists" or "already existed — created enrollment"
  • Run ensure entitlement site <url> on a site with no existing entitlement — verify FREE_TRIAL entitlement and enrollment are created as before
  • Run ensure entitlement imsorg on an org with an existing PAID entitlement — verify tier stays PAID
  • Run ensure entitlement imsorg on an org with no entitlement — verify FREE_TRIAL is created

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description. Or if there's no issue created, make sure you
    describe here the problem you're solving.
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

If the PR is changing the API specification:

  • make sure you add a "Not implemented yet" note the endpoint description, if the implementation is not ready
    yet. Ideally, return a 501 status code with a message explaining the feature is not implemented yet.
  • make sure you add at least one example of the request and response.

If the PR is changing the API implementation or an entity exposed through the API:

  • make sure you update the API specification and the examples to reflect the changes.

If the PR is introducing a new audit type:

  • make sure you update the API specification with the type, schema of the audit result and an example

Related Issues

Thanks for contributing!

@absarasw absarasw requested a review from ravverma April 17, 2026 19:35
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ravverma
Copy link
Copy Markdown
Contributor

Closing this PR as this should be handled on tier-client.

@ravverma ravverma closed this Apr 18, 2026
@habansal
Copy link
Copy Markdown
Contributor

replaced by adobe/spacecat-shared#1547

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.

3 participants