Skip to content

Commit 8e286a7

Browse files
JakeSCahillclaudegithub-actions[bot]
authored
Fix/array of objects and cloud docs check (#166)
* fix: Correctly render array-of-objects fields as empty arrays Array-of-objects fields like client_certs[] were incorrectly rendered as flat objects with all child properties expanded, creating invalid configurations that mixed mutually exclusive options. Changes: - buildConfigYaml.js: Check field.kind === 'array' to detect array-of-objects - renderObjectField.js: Same check for nested array-of-objects fields - Now renders 'client_certs: []' instead of expanded object structure This fixes 81 occurrences of client_certs plus other array-of-objects fields like tools[], roles[], sasl[], etc. Impact: 105 files changed in generated docs, removing 966 lines of incorrect expanded structures. Resolves issue where examples showed both inline (cert/key) and file-based (cert_file/key_file) options together, violating the documented 'either/or' constraint. * feat: Check cloud-docs repo for missing cloud-supported connectors Added logic to verify that all cloud-supported connectors (inCloud + cloudOnly) have corresponding documentation pages in the cloud-docs repository. Changes: - Build set of cloud-supported connectors from binary analysis - Use GitHub API to check if connector pages exist in cloud-docs - Report missing connectors with their paths - Runs automatically during draft-missing workflow (can be disabled) The check uses GitHub API (via Octokit) to avoid cloning the cloud-docs repo. Respects VBOT_GITHUB_API_TOKEN or GITHUB_TOKEN environment variables. Also improved cloud-only connector detection: - Cloud-only connectors now only check the cloud-only directory - Regular connectors check pages and partials (not cloud-only) This helps identify connectors that are available in Cloud but missing documentation pages in the cloud-docs repository. * fix: Surface non-404 errors in cloud-docs check Update cloud-docs validation to record and report non-404 API errors (auth, rate-limit, network) instead of silently ignoring them. - Add cloudDocsErrors array to track non-404 failures - Capture error status and message for each failure - Report inconclusive check with error details when failures occur - Only show success message when check completes without errors - Provide troubleshooting guidance for common error causes * fix: Preserve cloudOnly/requiresCgo flags and optimize octokit init - Preserve cloudOnly and requiresCgo flags when building validConnectors from dataObj so cloud-only connectors are properly detected - Move Octokit initialization outside the loop to reuse connection instead of creating a new instance for each connector check * feat: Add raw URL fallback for cloud-docs validation When GitHub API fails with auth/rate-limit errors, fall back to checking raw.githubusercontent.com URLs via HTTP HEAD request. Flow: 1. Try official API with authentication 2. If 404 -> file missing (expected) 3. If 403/401/rate-limit -> try raw URL fallback - 200 -> file exists (success) - 404 -> file missing (confirmed) - Other -> record error with both API and fallback details This allows validation to work even without GITHUB_TOKEN or when rate-limited, while still preferring the official API when available. * fix: Correct cloud-docs path and enable check without binary analysis - Fix cloud-docs path from modules/components/pages to modules/develop/pages/connect/components - Fix plural type handling (inputs not inputss) - Enable cloud-docs validation without binary analysis by checking all non-deprecated connectors when binary data unavailable - Reduces false positives from 282 to 64 actual missing connectors * feat: Auto-load .env files and fix cloud-docs validation Changes: - Add dotenv package for automatic .env file loading - Load .env files at startup in both CLI entry points - Fix cloud-docs validation to only check actual connector types Cloud-docs validation improvements: - Filter out config types (config/*) - internal schemas only - Filter out Bloblang functions/methods - documented on reference pages - Filter out rate-limits - documented differently - Only check: inputs, outputs, processors, caches, buffers, scanners, metrics, tracers Result: Validation now correctly reports ~7 missing connectors instead of 252 Benefits: - No more manual export of GITHUB_TOKEN needed - Binary analysis works automatically with .env file - Cloud-docs validation is accurate for connector coverage Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * docs: Auto-update CLI reference documentation (PR #166) * fix: Skip deprecated connectors in cloud-docs validation Deprecated connectors shouldn't be flagged as missing from cloud-docs. This filter reduces false positives (e.g., pg_stream which is deprecated). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * docs: Auto-update CLI reference documentation (PR #166) * fix: Downgrade dotenv to v16 to suppress promotional messages dotenv 17.x includes promotional stderr output that clutters CLI output. Downgraded to 16.x which provides the same functionality without the promotional messages. * docs: Auto-update CLI reference documentation (PR #166) * refactor: Consolidate Octokit instances into shared client Creates a centralized Octokit client singleton in cli-utils/octokit-client.js that is shared across all doc-tools modules. This eliminates redundant initialization, shares rate limit tracking, and works without authentication when no GitHub token is set. Changes: - Add cli-utils/octokit-client.js as shared singleton - Update 7 modules to use shared client: - tools/get-redpanda-version.js - tools/get-console-version.js - tools/fetch-from-github.js - tools/cloud-regions/generate-cloud-regions.js - extensions/generate-rp-connect-info.js - tools/redpanda-connect/connector-binary-analyzer.js - tools/redpanda-connect/rpcn-connector-docs-handler.js - Configure auth only when token is available - Simplify code by removing 38 lines of duplicate initialization Benefits: - Single initialization point for all GitHub API access - Shared rate limit pool across modules - Works without authentication (60 req/hr) or with token (5000 req/hr) - Easier to maintain and update configuration --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent f1bfca7 commit 8e286a7

14 files changed

+256
-62
lines changed

bin/doc-tools-mcp.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
* - Telemetry: Usage tracking for adoption metrics
1616
*/
1717

18+
// Load environment variables from .env file if it exists
19+
require('dotenv').config();
20+
1821
const fs = require('fs');
1922
const path = require('path');
2023
const { Server } = require('@modelcontextprotocol/sdk/server/index.js');

bin/doc-tools.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
'use strict'
44

5+
// Load environment variables from .env file if it exists
6+
require('dotenv').config()
7+
58
const { spawnSync } = require('child_process')
69
const os = require('os')
710
const { Command, Option } = require('commander')

cli-utils/octokit-client.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict'
2+
3+
const { Octokit } = require('@octokit/rest')
4+
const { getGitHubToken } = require('./github-token')
5+
6+
/**
7+
* Shared Octokit client instance for GitHub API access
8+
* Configured with optional authentication and retry logic
9+
*
10+
* This singleton instance is shared across all doc-tools modules to:
11+
* - Avoid redundant initialization
12+
* - Share rate limit tracking
13+
* - Centralize GitHub API configuration
14+
*/
15+
16+
// Get authentication token from environment
17+
const token = getGitHubToken()
18+
19+
// Configure Octokit options
20+
const octokitOptions = {
21+
userAgent: 'redpanda-docs-tools',
22+
retry: {
23+
enabled: true,
24+
retries: 3
25+
}
26+
}
27+
28+
// Only add auth if token is available
29+
if (token) {
30+
octokitOptions.auth = token
31+
}
32+
33+
// Create singleton instance
34+
const octokit = new Octokit(octokitOptions)
35+
36+
module.exports = octokit

extensions/generate-rp-connect-info.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ module.exports.register = function ({ config }) {
2525
// Use csvpath (legacy) or csvPath
2626
const localCsvPath = csvpath || null
2727

28-
async function loadOctokit () {
29-
const { Octokit } = await import('@octokit/rest')
30-
const { getGitHubToken } = require('../cli-utils/github-token')
31-
const token = getGitHubToken()
32-
return token ? new Octokit({ auth: token }) : new Octokit()
28+
function loadOctokit () {
29+
// Use shared Octokit client
30+
return require('../cli-utils/octokit-client')
3331
}
3432

3533
// Use 'on' and return the promise so Antora waits for async completion

package-lock.json

Lines changed: 18 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@redpanda-data/docs-extensions-and-macros",
3-
"version": "4.13.4",
3+
"version": "4.13.5",
44
"description": "Antora extensions and macros developed for Redpanda documentation.",
55
"keywords": [
66
"antora",
@@ -103,6 +103,7 @@
103103
"chalk": "4.1.2",
104104
"cheerio": "^1.1.2",
105105
"commander": "^14.0.0",
106+
"dotenv": "^16.6.1",
106107
"glob": "^11.0.0",
107108
"gulp": "^4.0.2",
108109
"gulp-connect": "^5.7.0",

tools/cloud-regions/generate-cloud-regions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ function displayClusterType(ct) {
7070
*/
7171
async function fetchYaml({ owner, repo, path, ref = 'main', token }) {
7272
try {
73-
const { Octokit } = await import('@octokit/rest');
74-
const octokit = new Octokit(token ? { auth: token } : {});
73+
// Use shared Octokit client
74+
const octokit = require('../../cli-utils/octokit-client');
7575

7676
console.log(`[cloud-regions] INFO: Fetching ${owner}/${repo}/${path}@${ref} via GitHub API`);
7777

tools/fetch-from-github.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
const fs = require('fs');
22
const path = require('path');
33

4-
let octokitInstance = null;
5-
async function loadOctokit() {
6-
if (!octokitInstance) {
7-
const { Octokit } = await import('@octokit/rest');
8-
octokitInstance = process.env.VBOT_GITHUB_API_TOKEN
9-
? new Octokit({
10-
auth: process.env.VBOT_GITHUB_API_TOKEN,
11-
})
12-
: new Octokit();
13-
14-
if (!process.env.VBOT_GITHUB_API_TOKEN) {
15-
console.info(
16-
'No GitHub token found (VBOT_GITHUB_API_TOKEN).'
17-
);
18-
}
19-
}
20-
return octokitInstance;
4+
// Use shared Octokit client
5+
function loadOctokit() {
6+
const octokit = require('../cli-utils/octokit-client');
7+
return octokit;
218
}
229

2310
async function saveFile(content, saveDir, filename) {

tools/get-console-version.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,8 @@ module.exports = async function getConsoleVersion({ beta = false, fromAntora = f
2323
useBeta = getPrereleaseFromAntora();
2424
}
2525

26-
// Initialize GitHub client
27-
const { getGitHubToken } = require('../cli-utils/github-token');
28-
const { Octokit } = await import('@octokit/rest');
29-
const token = getGitHubToken();
30-
const octokit = token
31-
? new Octokit({ auth: token })
32-
: new Octokit();
26+
// Use shared Octokit client
27+
const octokit = require('../cli-utils/octokit-client');
3328

3429
// Fetch latest release info
3530
let data;

tools/get-redpanda-version.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,8 @@ module.exports = async function getRedpandaVersion({ beta = false, fromAntora =
1919
useBeta = getPrereleaseFromAntora();
2020
}
2121

22-
// Load Octokit
23-
const { getGitHubToken } = require('../cli-utils/github-token');
24-
const { Octokit } = await import('@octokit/rest');
25-
const token = getGitHubToken();
26-
const octokit = token
27-
? new Octokit({ auth: token })
28-
: new Octokit();
22+
// Use shared Octokit client
23+
const octokit = require('../cli-utils/octokit-client');
2924

3025
// Fetch version data
3126
let data;

0 commit comments

Comments
 (0)