Skip to content

Accept per-tenant integration slug on /os/provision - #5

Closed
darjss wants to merge 1 commit into
mainfrom
feat/erxes-provision-integration-slug-v2
Closed

Accept per-tenant integration slug on /os/provision#5
darjss wants to merge 1 commit into
mainfrom
feat/erxes-provision-integration-slug-v2

Conversation

@darjss

@darjss darjss commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • /os/provision accepts optional integration in the POST body
  • Defaults to erxes-officenext when omitted (officenext unchanged)
  • Lets priuscenter register erxes-priuscenter on the shared executor

Test plan

  • Deploy to executor.os.erxes.io
  • Internal SSO still provisions under erxes-officenext
  • Body with integration: erxes-priuscenter creates a separate GraphQL integration

Replaces #4 (that PR accidentally included upstream UsefulSoftwareCo divergence).

Summary by Sourcery

Support tenant-specific integration provisioning while retaining the existing OfficeNext default.

New Features:

  • Allow /os/provision callers to select a valid per-tenant integration slug.
  • Preserve OfficeNext provisioning by defaulting omitted integration slugs to erxes-officenext.

Enhancements:

  • Use the selected integration slug consistently when looking up or creating integrations and connections.

Shared executor hosts multiple CF OS instances. Each gatekeeper sends its own
GraphQL integration slug so priuscenter does not clobber erxes-officenext.
@sourcery-ai

sourcery-ai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Reviewer's Guide

The provisioning endpoint now supports an optional validated integration slug, defaulting to erxes-officenext for backward compatibility, and consistently uses the selected slug when provisioning GraphQL integrations and connections.

Sequence diagram for per-tenant integration provisioning

sequenceDiagram
    participant Client
    participant Worker
    participant Executor

    Client->>Worker: POST /os/provision
    Worker->>Worker: parseIntegrationSlug(input.integration)
    alt Invalid integration slug
        Worker-->>Client: 400 Invalid request
    else Valid or omitted integration
        Worker->>Executor: GET /api/graphql/integrations/{integration}
        alt Integration missing
            Worker->>Executor: POST /api/graphql/integrations
            Executor-->>Worker: Integration created
        end
        Worker->>Executor: POST /api/connections
        Executor-->>Worker: Connection response
        Worker-->>Client: Provisioning response
    end
Loading

File-Level Changes

Change Details Files
Add optional, validated per-tenant integration slug handling while preserving the existing default.
  • Parse integration from the POST JSON body and default missing, null, or empty values to erxes-officenext.
  • Reject non-string or invalid slug formats with a 400 response.
  • Use the selected slug for integration lookup, creation, connection creation, and generated metadata.
apps/host-cloudflare/src/worker.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8c13ed5b-0e29-484e-97da-eabf55f80b09


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.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="apps/host-cloudflare/src/worker.ts" line_range="109-113" />
<code_context>
-        name: "OfficeNext",
-        description: "OfficeNext Erxes GraphQL API",
+        slug: integration,
+        name: integration,
+        description: `${integration} Erxes GraphQL API`,
         authenticationTemplate: [
</code_context>
<issue_to_address>
**issue (broader_impact):** The default `erxes-officenext` provisioning no longer preserves the existing OfficeNext-facing metadata: the integration name, description, connection name, identity label, and connection description become `erxes-officenext`-based values instead of `OfficeNext`/`Your OfficeNext account`. This breaks the stated compatibility guarantee that officenext remains unchanged and changes the labels shown to existing internal SSO users.

**Triggers:** When `integration` is omitted and the default OfficeNext integration is provisioned or its connection is refreshed.

**Suggested fix:** Keep the legacy OfficeNext metadata when `integration === DEFAULT_ERXES_INTEGRATION`, and use slug-derived metadata only for custom integrations.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and a caller-supplied slug now controls which integration is looked up and which integration and connection records are created, so an incorrect slug could associate credentials with the wrong integration and leave persisted records behind after a revert. The records and affected connection can be identified and removed or recreated, making the impact bounded and repairable.

Blocking findings: apps/host-cloudflare/src/worker.ts:113


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +109 to 113
name: integration,
description: `${integration} Erxes GraphQL API`,
authenticationTemplate: [
{
slug: "cookie",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (broader_impact): The default erxes-officenext provisioning no longer preserves the existing OfficeNext-facing metadata: the integration name, description, connection name, identity label, and connection description become erxes-officenext-based values instead of OfficeNext/Your OfficeNext account. This breaks the stated compatibility guarantee that officenext remains unchanged and changes the labels shown to existing internal SSO users.

Triggers: When integration is omitted and the default OfficeNext integration is provisioned or its connection is refreshed.

Suggested fix: Keep the legacy OfficeNext metadata when integration === DEFAULT_ERXES_INTEGRATION, and use slug-derived metadata only for custom integrations.

darjss added a commit that referenced this pull request Aug 31, 2026
Combines PR #3 (batched D1 writes, offline introspection, global_fetch_strictly_public)
with PR #5 (integration slug on /os/provision) for shared multi-tenant executor deploys.
@darjss

darjss commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Merged to main in f7a9911 (combined with #3).

@darjss darjss closed this Aug 31, 2026
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