Skip to content

docs: ServiceNow integration design note (Bytebase-first)#20477

Open
d-bytebase wants to merge 3 commits into
mainfrom
docs/servicenow-integration-design
Open

docs: ServiceNow integration design note (Bytebase-first)#20477
d-bytebase wants to merge 3 commits into
mainfrom
docs/servicenow-integration-design

Conversation

@d-bytebase

Copy link
Copy Markdown
Collaborator

What

Adds a design note at docs/design/servicenow-integration.md for integrating Bytebase's database-change approval and rollout with ServiceNow ITSM (CAB) approval, in a Bytebase-first model (user authors the change in the Bytebase UI; ServiceNow gates approval and drives the rollout via the public API).

Why

Recurring customer ask: unify the approval process so a database change created in Bytebase is mirrored to a ServiceNow CHG, and rollout is controlled by ServiceNow once the CHG is approved. This note captures the technical workflow, the enforcement model, and the integration gaps so we can have a grounded conversation with customers and scope any product work.

Contents

  • Architecture diagram (ASCII) and step-by-step flow.
  • Enforcement prerequisites — catch-all approval rule (unmatched issues auto-approve and bypass SN), bb.taskRuns.create lockdown to prevent UI bypass, per-environment RolloutPolicy.automatic=false.
  • Async rollout-creation race fixApproveIssue creates the rollout asynchronously, so the orchestrator must wait on has_rollout (or call CreateRollout explicitly, guarded for idempotency) before BatchRunTasks.
  • Failure / reject pathsRejectIssue, RequestIssue, BatchCancelTaskRuns, BatchSkipTasks.
  • Polling model — who polls, whether it's scalable, and how it works within ServiceNow (Flow Designer + MID Server) vs. a middleware service.
  • Security / audit — privileged service account, key rotation, audit attribution to the bot principal, connectivity.
  • Gaps — no generic outbound webhook (the highest-leverage fix), no external-ticket reference field, no external-approval state, no per-project "rollout only via API" toggle.
  • API-reference table for implementers.

Notes

  • Docs-only change; no code, proto, or schema changes.
  • Claims were verified against the current codebase (approval flow, webhook types, rollout policy, service-account auth, ListIssues filtering, rollout-creation timing).

🤖 Generated with Claude Code

Design note for integrating Bytebase change approval & rollout with
ServiceNow ITSM (CAB). Covers the Bytebase-first flow, enforcement
prerequisites (catch-all approval rule, bb.taskRuns.create lockdown,
per-env RolloutPolicy), the async rollout-creation race fix, failure/
reject paths, the polling model (who polls + scalability), security/
audit considerations, and the gaps (no generic outbound webhook, no
external-ticket field). Includes an API-reference table for implementers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@d-bytebase d-bytebase requested a review from a team as a code owner June 2, 2026 05:47
@cla-bot cla-bot Bot added the cla-signed label Jun 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc03261d19

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

- **Rejected →** `RejectIssue`. **Rework →** `RequestIssue`. Store the CHG ↔ issue mapping; link back via `CreateIssueComment` (include the **SN approver identity + CHG number** — see Security/Audit).
4. **Approve back (API).** On CHG approval, call `ApproveIssue` as the service account.
5. **Wait for the rollout to exist (race fix).** `ApproveIssue` creates the rollout **asynchronously** (it returns before stages/tasks exist). Do **not** call `BatchRunTasks` immediately. Either:
- poll `GetRollout` until `has_rollout == true` (simplest), **or**

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use the plan API when polling has_rollout

has_rollout is a Plan field, while RolloutService.GetRollout returns a Rollout that has no such field; the implementation also returns NotFound while plan.Config.HasRollout is false. An orchestrator following this step cannot observe has_rollout from GetRollout and may spin or fail after approval. This should instead say to retry GetRollout until it stops returning NotFound, or poll GetPlan/ListPlans for has_rollout.

Useful? React with 👍 / 👎.

d-bytebase and others added 2 commits June 1, 2026 22:51
…ServiceNow)

Document an optional design tradeoff to reduce the issue-created-to-CHG
discovery latency: reuse the existing TEAMS webhook type (allowlist
accepts *.powerplatform.com / *.logic.azure.com via suffix match) to
push ISSUE_CREATED into a Power Automate flow that creates the CHG via
its ServiceNow connector. Notes the reliability tradeoff (fire-and-forget,
no retry) and recommends a slow reconciliation poll as a backstop.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Webhook and polling are complementary, not either/or: webhook push for
low latency, reconciliation poll as the reliability backstop (Bytebase
webhooks are fire-and-forget with no retry). Issue-name idempotency makes
double-delivery safe. Same hybrid applies to status (PIPELINE_* webhook +
follow poll). Adds a source/role comparison table.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a2cf64dce

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

| Source | Role | Strength | Weakness |
|--------|------|----------|----------|
| **Webhook push** | primary | near-instant; no scan cost | fire-and-forget, 3s timeout, **no retry** → a dropped event is lost |
| **Reconciliation poll** | backstop | self-heals; also catches the catch-all-rule bypass and issues created while the endpoint was down | minute-level latency (ServiceNow) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add a separate scan for skipped approval bypasses

With the poll defined in step 2 (approval_status == "PENDING"), this reconciliation path will not catch the catch-all-rule bypass: unmatched issues are converted to ApprovalStatus_SKIPPED when no approval template is applied (computeApprovalStatus), not PENDING. If operators rely on this backstop to alert on misconfiguration, bypassed changes can still be missed; document a separate SKIPPED/no-CHG reconciliation or remove this claim.

Useful? React with 👍 / 👎.

Comment on lines +146 to +147
2. On issue creation Bytebase POSTs a MessageCard immediately (async, ~instant). The card carries the issue **link** (`.../projects/{project}/issues/{uid}`), title, status, and actor.
3. The Power Automate flow parses the card, extracts the issue ref (optionally calls `GetIssue` for detail), and creates the CHG via its native **ServiceNow connector**, storing the issue ↔ CHG mapping.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Parse the Power Automate adaptive-card envelope

For *.powerplatform.com/*.logic.azure.com URLs, the TEAMS receiver takes the postPowerAutomateMessage path, which sends an activity envelope containing an Adaptive Card; the MessageCard shape is only used by postMessage for legacy connector URLs. Following this wiring against a Power Automate HTTP trigger and parsing a MessageCard will miss the issue link/status fields, so the CHG creation flow should be documented against the adaptive-card payload instead.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant