Skip to content

feat(connect): normalize metadata partial field-list formatting#218

Open
JakeSCahill wants to merge 3 commits into
mainfrom
feat/normalize-metadata-formatting
Open

feat(connect): normalize metadata partial field-list formatting#218
JakeSCahill wants to merge 3 commits into
mainfrom
feat/normalize-metadata-formatting

Conversation

@JakeSCahill

Copy link
Copy Markdown
Contributor

Problem

Metadata partials are rendered verbatim from each connector's upstream == Metadata section, so formatting is inconsistent across connectors:

  • some wrap the field list in a fenced block of bare names (```text / ```, e.g. http_server, csv, gcp_cloud_storage, nats_kv)
  • others use an AsciiDoc bullet list with the field name in inline code (e.g. oracledb_cdc)

Reported on redpanda-data/rp-connect-docs#459.

Fix

Add normalize-metadata.js and apply it in renderConnectMetadata. For an extracted metadata block it:

  • strips the fences around a bare field list and renders the fields as a plain bullet list;
  • inline-codes the field name in each field bullet (- `http_server_user_agent`), keeping annotations ( - `mod_time` (RFC3339)) and descriptions (- `operation`: …);
  • leaves descriptive bullets ("All headers (only first values are taken)") as prose;
  • leaves already inline-coded bullets untouched;
  • preserves === subheadings that legitimately group metadata by operation (e.g. the nats_kv processor);
  • keeps non-field fenced blocks (YAML examples) verbatim.

Field names are detected as lowercase snake_case leading tokens, which cleanly distinguishes them from descriptive bullets.

Tests

npx jest __tests__/tools/metadata-partials.test.js → 23 passing, including a new normalize-metadata suite covering the ```text/bare-fence/nats_kv/mod_time (RFC3339)/YAML-example cases. Two existing assertions updated to expect inline-coded field names.

Related

@netlify

netlify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploy Preview for docs-extensions-and-macros ready!

Name Link
🔨 Latest commit 34f9c87
🔍 Latest deploy log https://app.netlify.com/projects/docs-extensions-and-macros/deploys/6a6354bb1d9f7700087cf957
😎 Deploy Preview https://deploy-preview-218--docs-extensions-and-macros.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 00026add-8cb6-4081-b9b0-97c883a5e297

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds normalizeMetadataBlock to standardize connector metadata field lists by removing qualifying fences and wrapping field names in inline code. renderConnectMetadata now applies this normalization to extracted metadata. Tests cover fenced and unfenced lists, annotations, subheadings, preserved inline code, non-field-list fences, and updated rendered output.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ConnectorDescription
  participant extractMetadata
  participant normalizeMetadataBlock
  participant MetadataRenderer
  ConnectorDescription->>extractMetadata: extract Metadata block
  extractMetadata->>normalizeMetadataBlock: pass extracted block
  normalizeMetadataBlock->>MetadataRenderer: return normalized metadata
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: normalizing metadata field-list formatting in connect.
Description check ✅ Passed The description is directly about the metadata normalization changes and associated tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/normalize-metadata-formatting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tools/redpanda-connect/normalize-metadata.js (1)

40-46: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

isFieldListFence doesn't verify any bullet is actually a field name.

The check only requires every non-blank line to look like a bullet (BULLET.test(l)), not that at least one bullet matches the field-name pattern (FIELD_BULLET). A fenced block containing only descriptive/prose bullets (no real snake_case field name) would still be misclassified as a field list and have its fences stripped, unintentionally changing the rendered doc's formatting.

🐛 Proposed fix requiring at least one real field-name bullet
 function isFieldListFence (infoString, contentLines) {
   const info = infoString.trim();
   if (info !== '' && info !== 'text') return false;
   const nonBlank = contentLines.filter((l) => l.trim() !== '');
-  return nonBlank.length > 0 && nonBlank.every((l) => BULLET.test(l));
+  return nonBlank.length > 0 && nonBlank.every((l) => BULLET.test(l)) &&
+    nonBlank.some((l) => {
+      const b = l.match(BULLET);
+      return b && FIELD_BULLET.test(b[2]);
+    });
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/redpanda-connect/normalize-metadata.js` around lines 40 - 46, Update
isFieldListFence to require at least one non-blank line matching FIELD_BULLET,
while preserving the existing info-string and all-lines-BULLET checks. Fences
containing only descriptive bullets must not be classified as field lists or
stripped.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tools/redpanda-connect/normalize-metadata.js`:
- Around line 40-46: Update isFieldListFence to require at least one non-blank
line matching FIELD_BULLET, while preserving the existing info-string and
all-lines-BULLET checks. Fences containing only descriptive bullets must not be
classified as field lists or stripped.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a71d9103-03b7-41c2-90a4-fe92e5191843

📥 Commits

Reviewing files that changed from the base of the PR and between f491c85 and 3eaa7d6.

📒 Files selected for processing (3)
  • __tests__/tools/metadata-partials.test.js
  • tools/redpanda-connect/helpers/renderConnectMetadata.js
  • tools/redpanda-connect/normalize-metadata.js

@Feediver1

Copy link
Copy Markdown
Contributor

Recommended fix:
AsciiDoc listing blocks aren't guarded. extractMetadata (in metadata-utils.js) explicitly tracks ---- delimiters so it doesn't misread headings inside them — evidence that ---- blocks occur in these descriptions. But normalizeMetadataBlock only recognizes ``` and ~~~. If a connector's Metadata section wraps content in ----, any - field_name line inside that literal block gets backtick-wrapped, and backticks inside a literal block render as visible backticks on the page — a regression the current tests wouldn't catch. Fix is small: track BLOCK_DELIMITER = /^-{4,}$/ state in the main loop and pass those regions through verbatim, plus one test.

Minor suggestions:

  • Mismatched fence close: FENCE_CLOSE matches either or ~~~, so a block opened with can be "closed" by ~~~. Cheap fix: capture the opening fence and require the same one to close.
  • False-positive surface in FIELD_BULLET: any bullet starting with a lowercase word followed by : or - gets coded (for example a hypothetical - note: this only applies to... would become - note: ...). The heuristic is reasonable and the PR body owns it; just be aware the first regeneration over all connectors should be diff-reviewed rather than trusted (consistent with how we handle property regen drift).
  • Unclosed-fence handling is correct (falls back to verbatim) but untested — a one-liner test would pin it.

Metadata partials were rendered verbatim from each connector's upstream
description, so formatting was inconsistent: some field lists are fenced
```text blocks of bare names, others are AsciiDoc bullet lists with the
field name in inline code.

Add a normalization pass (applied in renderConnectMetadata): strip fences
around a bare field list and render the fields as a bullet list with the
field name in inline code. Descriptive bullets ("All headers ...") stay
prose, already inline-coded bullets are left alone, `===` subheadings that
group metadata by operation (e.g. nats_kv) are preserved, and non-field
fenced blocks (YAML examples) are kept verbatim.

Adds a normalize-metadata test suite; updates two existing assertions to
expect inline-coded field names.
…escriptions

The metadata normalizer missed two real field-bullet shapes:
- fields separated from their description by " - " instead of ":"
  (command, retry, gcp_pubsub) — the field-bullet pattern only accepted
  ":" or a parenthetical annotation.
- fields whose description contains inline code (mongodb_cdc `schema`,
  oracledb `transaction_id`/`commit_ts_ms`) — the skip guard checked the
  whole line for a backtick, so a backtick anywhere in the description
  prevented coding the field name.

Broaden the pattern to accept a " - " separator and change the guard to
skip only when the field name itself is already inline-coded. Add tests
for both shapes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants