Skip to content

fix(generate-rpcn-connector-docs): buildConfigYaml adds label field to component types that don't support it #176

@mfernest

Description

@mfernest

Summary

buildConfigYaml.js unconditionally adds label: "" to the generated example YAML for every component type. However, label is only valid for inputs, outputs, and processors. All other component types — metrics, caches, buffers, tracers, rate-limits, and scanners — do not support label, so the generated examples are incorrect.

Root cause

In tools/redpanda-connect/helpers/buildConfigYaml.js, line 27:

module.exports = function buildConfigYaml(type, connectorName, children, includeAdvanced) {
  const lines = [];
  lines.push(`${type}:`);
  lines.push(`  label: ""`);  // ← always added, no type check
  lines.push(`  ${connectorName}:`);
  // ...
}

The caller in generate-rpcn-connector-docs.js (lines 473–492) iterates over all types and calls commonConfig / advancedConfig without filtering, so buildConfigYaml is invoked for all of: buffers, caches, inputs, metrics, outputs, processors, rate-limits, scanners, tracers.

Affected component types (currently incorrect)

Type # components Has label?
metrics 7 ❌ No
caches 17 ❌ No
buffers 4 ❌ No
tracers 5 ❌ No
rate-limits 2 ❌ No
scanners 12 ❌ No
inputs 80 ✅ Yes
outputs 85 ✅ Yes
processors 96 ✅ Yes

Suggested fix

In buildConfigYaml.js, guard the label line:

const TYPES_WITH_LABEL = new Set(['inputs', 'outputs', 'processors']);

module.exports = function buildConfigYaml(type, connectorName, children, includeAdvanced) {
  const lines = [];
  lines.push(`${type}:`);
  if (TYPES_WITH_LABEL.has(type)) {
    lines.push(`  label: ""`);
  }
  lines.push(`  ${connectorName}:`);
  // ...
}

Impact

This was reported by a community member via Slack (DOC-1978) specifically for the metrics pages. A manual fix was applied in rp-connect-docs#381 for the metrics examples, but the same bug affects 5 other component type categories and will reappear on the next doc generation run without a fix here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions