Skip to content

feat(ci): guard against self-referencing frontmatter - #1070

Draft
klocke-io wants to merge 1 commit into
masterfrom
feature/ci-frontmatter-selfref-check
Draft

feat(ci): guard against self-referencing frontmatter#1070
klocke-io wants to merge 1 commit into
masterfrom
feature/ci-frontmatter-selfref-check

Conversation

@klocke-io

Copy link
Copy Markdown
Member

How to categorize this PR?

/kind bug
/kind enhancement

What this PR does / why we need it:

This is a proposal for a CI check that prevents a class of frontmatter misclassification bug.

The problem: docforge aggregates upstream markdown into hugo/content/ and tags each file with github_repo. The banner step (post-processing/lib/banner.js -> classify) treats any file with github_repo as MANAGED (read-only, overwritten nightly). Files without it are LOCAL (source of truth).

A file whose github_repo points at github.com/gardener/documentation itself is a self-reference. Real upstream content never lives in the documentation repo, so such a value almost certainly means locally maintained content was accidentally tagged as aggregated. It then gets a MANAGED banner despite being the source of truth, and it is in no docforge manifest.

Concrete example: hugo/content/community/hackathons/2026-11.md was committed locally, then a later aggregation run injected github_repo: 'https://github.com/gardener/documentation'. It ended up wrongly classified as MANAGED, and contradictorily carried both local: true and a MANAGED banner.

What the check does:

  • New post-processing/lib/selfref.js: isSelfReference() + findViolations(), flagging
    1. github_repo pointing at gardener/documentation (self-reference)
    2. local: true combined with any github_repo (contradictory)
  • New post-processing/check-frontmatter.js: scans every *.md under hugo/content/, uses the existing lib/frontmatter.js read(), exits 1 on violations.
  • New .github/workflows/check-frontmatter.yml: runs the check on content PRs (mirrors enforce-managed-files.yml style, pinned action SHAs).
  • Unit tests in post-processing/lib/selfref.test.js (node:test, assert/strict) following the existing lib/*.test.js style.

Special notes for your reviewer:

  • This PR intentionally does not fix 2026-11.md (handled separately). Running the check on master currently fails on exactly that file, which demonstrates it catches the real bug.
  • node --test post-processing/lib/selfref.test.js -> 15/15 pass.
  • Proposal: open for discussion on whether the self-reference regex and the two rules match your intent.

Add a CI check that fails when a file under hugo/content/ carries a
github_repo pointing at gardener/documentation itself (self-reference)
or combines local: true with github_repo. Both indicate local content
wrongly tagged as aggregated, which makes the banner step classify it
as read-only MANAGED.

- post-processing/lib/selfref.js: detection logic + tests
- post-processing/check-frontmatter.js: CLI scanning hugo/content
- .github/workflows/check-frontmatter.yml: run on content PRs
@gardener-prow gardener-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Bug labels Sep 1, 2026
@gardener-prow

gardener-prow Bot commented Sep 1, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign klocke-io for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gardener-prow gardener-prow Bot added the kind/enhancement Enhancement, improvement, extension label Sep 1, 2026
@netlify

netlify Bot commented Sep 1, 2026

Copy link
Copy Markdown

Deploy Preview for gardener-docs ready!

Name Link
🔨 Latest commit 6bdcc91
🔍 Latest deploy log https://app.netlify.com/projects/gardener-docs/deploys/6a968b0495c61f0008673241
😎 Deploy Preview https://deploy-preview-1070--gardener-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

@gardener-prow gardener-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Sitemap structure diff vs master

count
➕ added pages 0
➖ removed pages 0

First entries (full diff in the run summary & artifact):

ADDED   (0):
  (none)
REMOVED (0):
  (none)

A rename appears as one removed (old path) + one added (new path).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Bug kind/enhancement Enhancement, improvement, extension size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant