Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(docs): isolate data sync credentials

jkomyno46bc17864e47
diff --git a/.github/workflows/docs-update-data.yml b/.github/workflows/docs-update-data.yml
index 0d4ae0bd0..beaee8877 100644
--- a/.github/workflows/docs-update-data.yml
+++ b/.github/workflows/docs-update-data.yml
@@ -46,12 +46,14 @@ jobs:
private-key: ${{ secrets.RELEASE_BOT_APP_PRIVATE_KEY }}
owner: ComposioHQ
repositories: composio
+ # Same-repository issue tracking uses github.token under the job-level
+ # issues grant; do not widen this app token for issue operations.
permission-contents: write
permission-pull-requests: write
- permission-issues: write
- name: Generate read-only KB source token
id: source-token
+ continue-on-error: true
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ vars.RELEASE_BOT_CLIENT_ID }}
@@ -125,6 +127,9 @@ jobs:
GH_TOKEN: ${{ steps.source-token.outputs.token }}
run: |
set +e
+ if [ -z "${GH_TOKEN:-}" ]; then
+ echo "KB source token unavailable; source-pin status will be unverifiable."
+ fi
bun scripts/verify-kb.ts --check-links --check-source-pin \
--markdown "$RUNNER_TEMP/kb-freshness.md"
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
@@ -187,7 +192,7 @@ jobs:
# public/data/toolkits.json, the docs site keeps building from the last
# good commit, and nothing 500s — new toolkits simply 404. That is how a
# credential failure went unnoticed for 60 consecutive runs. File one
- # tracking issue and leave it open until someone fixes the cause.
+ # tracking issue and close it after the next successful run proves recovery.
- name: Open tracking issue on failure
if: failure()
continue-on-error: true
@@ -230,8 +235,23 @@ jobs:
**production** read access against \`backend.composio.dev\`. Note this job does
not use the shared \`COMPOSIO_API_KEY\`, which is staging-scoped.
- This issue is filed once and left open until the cause is fixed; it will not be
- re-filed on every run."
+ This issue is filed once, not re-filed on every run, and automatically closes
+ after the next successful sync proves recovery."
+
+ - name: Close tracking issue on recovery
+ if: success()
+ continue-on-error: true
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GH_REPO: ${{ github.repository }}
+ LABEL: docs-data-sync-failure
+ run: |
+ existing=$(gh issue list --label "$LABEL" --state open --limit 1 \
+ --json number --jq '.[0].number // empty')
+ if [ -n "$existing" ]; then
+ gh issue close "$existing" \
+ --comment "The docs data sync recovered in run ${{ github.run_id }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}."
+ fi
# A verifier crash is a tooling failure, not evidence that published guides
# contradict production. Track it separately and close it after the verifier
@@ -240,7 +260,7 @@ jobs:
if: always() && steps.verify-kb.outputs.exit_code != ''
continue-on-error: true
env:
- GH_TOKEN: ${{ steps.app-token.outputs.token }}
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERIFY_EXIT: ${{ steps.verify-kb.outputs.exit_code }}
LABEL: kb-freshness-check-failure
TITLE: 'KB freshness verifier is failing'
@@ -283,7 +303,7 @@ jobs:
if: always() && (steps.verify-kb.outputs.exit_code == '0' || steps.verify-kb.outputs.exit_code == '1')
continue-on-error: true
env:
- GH_TOKEN: ${{ steps.app-token.outputs.token }}
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERIFY_EXIT: ${{ steps.verify-kb.outputs.exit_code }}
TITLE: 'KB freshness: published guides contradict production data'
run: |
diff --git a/docs/tests/static/docs-data-workflow.test.ts b/docs/tests/static/docs-data-workflow.test.ts
new file mode 100644
index 000000000..ba19ff317
--- /dev/null
+++ b/docs/tests/static/docs-data-workflow.test.ts
@@ -0,0 +1,116 @@
+import { describe, expect, test } from 'bun:test';
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+
+const workflowPath = resolve(process.cwd(), '..', '.github', 'workflows', 'docs-update-data.yml');
+
+interface WorkflowStep {
+ name?: string;
+ id?: string;
+ uses?: string;
+ if?: string;
+ 'continue-on-error'?: boolean;
+ 'working-directory'?: string;
+ env?: Record<string, unknown>;
+ with?: Record<string, unknown>;
+ run?: string;
+}
+
+function workflowSteps(path: string, job: string): WorkflowStep[] {
+ const workflow = Bun.YAML.parse(readFileSync(path, 'utf8')) as {
+ jobs?: Record<string, { steps?: WorkflowStep[] }>;
+ };
+ return workflow.jobs?.[job]?.steps ?? [];
+}
+
+function stepNamed(steps: WorkflowStep[], name: string): WorkflowStep {
+ const step = steps.find(candidate => candidate.name === name);
+ expect(step, `Expected workflow step "${name}"`).toBeDefined();
+ return step ?? {};
+}
+
+describe('docs data update workflow', () => {
+ const steps = workflowSteps(workflowPath, 'update-data');
+
+ test('keeps the release-bot token scoped to data sync and PR creation', () => {
+ const appToken = stepNamed(steps, 'Generate GitHub App token');
+
+ expect(appToken.with?.['permission-contents']).toBe('write');
+ expect(appToken.with?.['permission-pull-requests']).toBe('write');
+ expect(appToken.with).not.toHaveProperty('permission-issues');
+ });
+
+ test('uses the job token for all same-repository issue tracking', () => {
+ const issueSteps = [
+ 'Open tracking issue on failure',
+ 'Close tracking issue on recovery',
+ 'Track KB freshness verifier health',
+ 'Track KB freshness findings',
+ ];
+
+ for (const name of issueSteps) {
+ expect(stepNamed(steps, name).env?.GH_TOKEN).toBe('${{ secrets.GITHUB_TOKEN }}');
+ }
+
+ for (const step of steps.filter(candidate => candidate.run?.includes('gh issue'))) {
+ expect(step.env?.GH_TOKEN).not.toBe('${{ steps.app-token.outputs.token }}');
+ }
+ });
+
+ test('isolates the optional KB source path from every required data-sync step', () => {
+ const sourceToken = stepNamed(steps, 'Generate read-only KB source token');
+ expect(sourceToken['continue-on-error']).toBe(true);
+
+ const requiredStepNames = [
+ 'Generate GitHub App token',
+ 'Checkout repository',
+ 'Generate toolkits data',
+ 'Fetch OpenAPI spec',
+ 'Generate API index pages',
+ 'Generate meta tools reference',
+ 'Create Pull Request',
+ ];
+
+ for (const name of requiredStepNames) {
+ const step = stepNamed(steps, name);
+ const dependencies = JSON.stringify({ if: step.if, env: step.env, with: step.with });
+ expect(dependencies).not.toContain('steps.source-token');
+ expect(dependencies).not.toContain('steps.verify-kb');
+ }
+ });
+
+ test('keeps the generated-data pull request scope and target stable', () => {
+ const createPullRequest = stepNamed(steps, 'Create Pull Request');
+ const addPaths = String(createPullRequest.with?.['add-paths']);
+
+ expect(createPullRequest.with?.branch).toBe('docs/auto-update-data');
+ expect(createPullRequest.with?.base).toBe('next');
+ for (const path of [
+ 'docs/public/data/',
+ 'docs/public/openapi.json',
+ 'docs/public/openapi-v3.json',
+ 'docs/public/openapi-webhooks.json',
+ 'docs/content/reference/api-reference/',
+ 'docs/content/reference/v3/api-reference/',
+ 'docs/content/toolkits/meta-tools/',
+ ]) {
+ expect(addPaths).toContain(path);
+ }
+ });
+
+ test('opens failures before checkout and closes the issue after recovery', () => {
+ const failure = stepNamed(steps, 'Open tracking issue on failure');
+ const recovery = stepNamed(steps, 'Close tracking issue on recovery');
+
+ expect(failure.if).toBe('failure()');
+ expect(failure['working-directory']).toBe('${{ github.workspace }}');
+ expect(failure.env?.GH_TOKEN).toBe('${{ secrets.GITHUB_TOKEN }}');
+ expect(failure.env?.LABEL).toBe('docs-data-sync-failure');
+
+ expect(recovery.if).toBe('success()');
+ expect(recovery.env?.LABEL).toBe('docs-data-sync-failure');
+ expect(recovery.run).toContain('gh issue list');
+ expect(recovery.run).toContain('gh issue close');
+ expect(recovery.run).toContain('${{ github.run_id }}');
+ });
+});