@devries-cameron20 / composio-1 / commits / 46bc17864
Fork 0

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

jkomyno committed Aug 25, 2026 at 03:22 UTC 46bc17864e47903ea01013f45837a3b24c6acb75
2 files changed +142 -6
.github/workflows/docs-update-data.yml
+26 -6
@@ -46,12 +46,14 @@ jobs:
46 private-key: ${{ secrets.RELEASE_BOT_APP_PRIVATE_KEY }}
47 owner: ComposioHQ
48 repositories: composio
49 + # Same-repository issue tracking uses github.token under the job-level
50 + # issues grant; do not widen this app token for issue operations.
51 permission-contents: write
52 permission-pull-requests: write
51 - permission-issues: write
53
54 - name: Generate read-only KB source token
55 id: source-token
56 + continue-on-error: true
57 uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
58 with:
59 client-id: ${{ vars.RELEASE_BOT_CLIENT_ID }}
@@ -125,6 +127,9 @@ jobs:
127 GH_TOKEN: ${{ steps.source-token.outputs.token }}
128 run: |
129 set +e
130 + if [ -z "${GH_TOKEN:-}" ]; then
131 + echo "KB source token unavailable; source-pin status will be unverifiable."
132 + fi
133 bun scripts/verify-kb.ts --check-links --check-source-pin \
134 --markdown "$RUNNER_TEMP/kb-freshness.md"
135 echo "exit_code=$?" >> "$GITHUB_OUTPUT"
@@ -187,7 +192,7 @@ jobs:
192 # public/data/toolkits.json, the docs site keeps building from the last
193 # good commit, and nothing 500s — new toolkits simply 404. That is how a
194 # credential failure went unnoticed for 60 consecutive runs. File one
190 - # tracking issue and leave it open until someone fixes the cause.
195 + # tracking issue and close it after the next successful run proves recovery.
196 - name: Open tracking issue on failure
197 if: failure()
198 continue-on-error: true
@@ -230,8 +235,23 @@ jobs:
235 **production** read access against \`backend.composio.dev\`. Note this job does
236 not use the shared \`COMPOSIO_API_KEY\`, which is staging-scoped.
237
233 - This issue is filed once and left open until the cause is fixed; it will not be
234 - re-filed on every run."
238 + This issue is filed once, not re-filed on every run, and automatically closes
239 + after the next successful sync proves recovery."
240 +
241 + - name: Close tracking issue on recovery
242 + if: success()
243 + continue-on-error: true
244 + env:
245 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
246 + GH_REPO: ${{ github.repository }}
247 + LABEL: docs-data-sync-failure
248 + run: |
249 + existing=$(gh issue list --label "$LABEL" --state open --limit 1 \
250 + --json number --jq '.[0].number // empty')
251 + if [ -n "$existing" ]; then
252 + gh issue close "$existing" \
253 + --comment "The docs data sync recovered in run ${{ github.run_id }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}."
254 + fi
255
256 # A verifier crash is a tooling failure, not evidence that published guides
257 # contradict production. Track it separately and close it after the verifier
@@ -240,7 +260,7 @@ jobs:
260 if: always() && steps.verify-kb.outputs.exit_code != ''
261 continue-on-error: true
262 env:
243 - GH_TOKEN: ${{ steps.app-token.outputs.token }}
263 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
264 VERIFY_EXIT: ${{ steps.verify-kb.outputs.exit_code }}
265 LABEL: kb-freshness-check-failure
266 TITLE: 'KB freshness verifier is failing'
@@ -283,7 +303,7 @@ jobs:
303 if: always() && (steps.verify-kb.outputs.exit_code == '0' || steps.verify-kb.outputs.exit_code == '1')
304 continue-on-error: true
305 env:
286 - GH_TOKEN: ${{ steps.app-token.outputs.token }}
306 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
307 VERIFY_EXIT: ${{ steps.verify-kb.outputs.exit_code }}
308 TITLE: 'KB freshness: published guides contradict production data'
309 run: |
docs/tests/static/docs-data-workflow.test.ts new
+116
@@ -0,0 +1,116 @@
1 +import { describe, expect, test } from 'bun:test';
2 +import { readFileSync } from 'node:fs';
3 +import { resolve } from 'node:path';
4 +
5 +const workflowPath = resolve(process.cwd(), '..', '.github', 'workflows', 'docs-update-data.yml');
6 +
7 +interface WorkflowStep {
8 + name?: string;
9 + id?: string;
10 + uses?: string;
11 + if?: string;
12 + 'continue-on-error'?: boolean;
13 + 'working-directory'?: string;
14 + env?: Record<string, unknown>;
15 + with?: Record<string, unknown>;
16 + run?: string;
17 +}
18 +
19 +function workflowSteps(path: string, job: string): WorkflowStep[] {
20 + const workflow = Bun.YAML.parse(readFileSync(path, 'utf8')) as {
21 + jobs?: Record<string, { steps?: WorkflowStep[] }>;
22 + };
23 + return workflow.jobs?.[job]?.steps ?? [];
24 +}
25 +
26 +function stepNamed(steps: WorkflowStep[], name: string): WorkflowStep {
27 + const step = steps.find(candidate => candidate.name === name);
28 + expect(step, `Expected workflow step "${name}"`).toBeDefined();
29 + return step ?? {};
30 +}
31 +
32 +describe('docs data update workflow', () => {
33 + const steps = workflowSteps(workflowPath, 'update-data');
34 +
35 + test('keeps the release-bot token scoped to data sync and PR creation', () => {
36 + const appToken = stepNamed(steps, 'Generate GitHub App token');
37 +
38 + expect(appToken.with?.['permission-contents']).toBe('write');
39 + expect(appToken.with?.['permission-pull-requests']).toBe('write');
40 + expect(appToken.with).not.toHaveProperty('permission-issues');
41 + });
42 +
43 + test('uses the job token for all same-repository issue tracking', () => {
44 + const issueSteps = [
45 + 'Open tracking issue on failure',
46 + 'Close tracking issue on recovery',
47 + 'Track KB freshness verifier health',
48 + 'Track KB freshness findings',
49 + ];
50 +
51 + for (const name of issueSteps) {
52 + expect(stepNamed(steps, name).env?.GH_TOKEN).toBe('${{ secrets.GITHUB_TOKEN }}');
53 + }
54 +
55 + for (const step of steps.filter(candidate => candidate.run?.includes('gh issue'))) {
56 + expect(step.env?.GH_TOKEN).not.toBe('${{ steps.app-token.outputs.token }}');
57 + }
58 + });
59 +
60 + test('isolates the optional KB source path from every required data-sync step', () => {
61 + const sourceToken = stepNamed(steps, 'Generate read-only KB source token');
62 + expect(sourceToken['continue-on-error']).toBe(true);
63 +
64 + const requiredStepNames = [
65 + 'Generate GitHub App token',
66 + 'Checkout repository',
67 + 'Generate toolkits data',
68 + 'Fetch OpenAPI spec',
69 + 'Generate API index pages',
70 + 'Generate meta tools reference',
71 + 'Create Pull Request',
72 + ];
73 +
74 + for (const name of requiredStepNames) {
75 + const step = stepNamed(steps, name);
76 + const dependencies = JSON.stringify({ if: step.if, env: step.env, with: step.with });
77 + expect(dependencies).not.toContain('steps.source-token');
78 + expect(dependencies).not.toContain('steps.verify-kb');
79 + }
80 + });
81 +
82 + test('keeps the generated-data pull request scope and target stable', () => {
83 + const createPullRequest = stepNamed(steps, 'Create Pull Request');
84 + const addPaths = String(createPullRequest.with?.['add-paths']);
85 +
86 + expect(createPullRequest.with?.branch).toBe('docs/auto-update-data');
87 + expect(createPullRequest.with?.base).toBe('next');
88 + for (const path of [
89 + 'docs/public/data/',
90 + 'docs/public/openapi.json',
91 + 'docs/public/openapi-v3.json',
92 + 'docs/public/openapi-webhooks.json',
93 + 'docs/content/reference/api-reference/',
94 + 'docs/content/reference/v3/api-reference/',
95 + 'docs/content/toolkits/meta-tools/',
96 + ]) {
97 + expect(addPaths).toContain(path);
98 + }
99 + });
100 +
101 + test('opens failures before checkout and closes the issue after recovery', () => {
102 + const failure = stepNamed(steps, 'Open tracking issue on failure');
103 + const recovery = stepNamed(steps, 'Close tracking issue on recovery');
104 +
105 + expect(failure.if).toBe('failure()');
106 + expect(failure['working-directory']).toBe('${{ github.workspace }}');
107 + expect(failure.env?.GH_TOKEN).toBe('${{ secrets.GITHUB_TOKEN }}');
108 + expect(failure.env?.LABEL).toBe('docs-data-sync-failure');
109 +
110 + expect(recovery.if).toBe('success()');
111 + expect(recovery.env?.LABEL).toBe('docs-data-sync-failure');
112 + expect(recovery.run).toContain('gh issue list');
113 + expect(recovery.run).toContain('gh issue close');
114 + expect(recovery.run).toContain('${{ github.run_id }}');
115 + });
116 +});