Skip to content

Conversation

@dohernandez
Copy link
Member

@dohernandez dohernandez commented Jul 30, 2025

Description

This PR fixes a critical issue in the sanitize-config.py script where the regex patterns were too greedy, causing the removal of entire configuration sections beyond just the admin and dev sections. The script now uses a line-by-line approach with proper indentation tracking to accurately identify and remove only the targeted sections while preserving all other configuration elements like rpc, ops, and other node settings.

Summary by CodeRabbit

  • Refactor
    • Improved the method for removing specific sections from YAML configuration files, resulting in more accurate and reliable sanitization.

@netlify
Copy link

netlify bot commented Jul 30, 2025

Deploy Preview for genlayer-docs ready!

Name Link
🔨 Latest commit 237c4c1
🔍 Latest deploy log https://app.netlify.com/projects/genlayer-docs/deploys/688a4e0a50bf450008277edb
😎 Deploy Preview https://deploy-preview-264--genlayer-docs.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
Copy link
Contributor

coderabbitai bot commented Jul 30, 2025

Walkthrough

The script .github/scripts/sanitize-config.py was refactored to remove node.dev and node.admin sections from YAML files using a line-by-line, indentation-aware parsing approach instead of regex-based substitutions. A helper function was introduced to determine section boundaries, and file size reporting was updated to reflect the new logic.

Changes

Cohort / File(s) Change Summary
Sanitization Logic Refactor
.github/scripts/sanitize-config.py
Replaced regex-based section removal with indentation-aware line parsing; added helper for section end detection; updated file size reporting.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Script
    participant YAML_File

    User->>Script: Run sanitize_config(config_file_path)
    Script->>YAML_File: Read lines from file
    Script->>Script: Identify node.dev and node.admin sections by indentation
    Script->>Script: Remove identified section lines
    Script->>YAML_File: Write sanitized lines back to file
    Script->>User: Print updated file size
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

In the warren, code is neat,
Indents guide my rabbit feet.
Regex gone, now lines I scan,
YAML’s secrets, I unjam.
With every hop, a section ends—
Clean configs, my fluffy friends!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5413d8 and 237c4c1.

📒 Files selected for processing (1)
  • .github/scripts/sanitize-config.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/scripts/sanitize-config.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Redirect rules - genlayer-docs
  • GitHub Check: Header rules - genlayer-docs
  • GitHub Check: Pages changed - genlayer-docs
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/automate-config

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/scripts/sanitize-config.py (1)

10-10: Remove unused import.

The re module is no longer needed since the script was refactored away from regex-based processing.

-import re
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c2f3982 and a5413d8.

📒 Files selected for processing (1)
  • .github/scripts/sanitize-config.py (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: dohernandez
PR: genlayerlabs/genlayer-docs#257
File: .github/workflows/sync-docs-from-node.yml:0-0
Timestamp: 2025-07-26T13:26:45.588Z
Learning: In the sync-docs-from-node.yml workflow, the user prefers selective git staging with `git add content/validators pages/api-references pages/validators` rather than `git add -A` to avoid staging unintended changes, as these are the expected directories to be modified during the documentation sync process.
🔇 Additional comments (6)
.github/scripts/sanitize-config.py (6)

13-35: LGTM! Well-structured helper function for YAML section parsing.

The function correctly implements indentation-based section boundary detection. The logic for skipping empty lines and comments is sound, and the end-of-file handling is appropriate.


47-52: Good approach using line-by-line processing.

The shift from regex to line-based processing with splitlines(keepends=True) and using a set to track removals is a solid approach that addresses the original greedy regex issue.


79-92: Section removal logic is well-implemented.

The approach of marking lines for removal and then filtering them out is efficient and correct. The logging of removed sections provides good visibility into the sanitization process.


101-101: File size calculation correctly adapted for line-based approach.

The updated calculation using sum(len(line) for line in new_lines) properly reflects the new line-based processing approach.


105-117: Main function has proper error handling and validation.

The command-line argument validation and exception handling are implemented correctly with appropriate error messages and exit codes.


60-78: Backwards search logic is robust — no changes needed

  • The stripped check (line.strip()) prevents commented-out lines (# node:) or string values ("node:") from matching as a parent.
  • The backwards scan correctly stops at the first lower-indent header, so it will always associate admin:/dev: with the nearest enclosing node: section.
  • No admin: or dev: keys are present in the sampled YAML files, so there’s no immediate edge-case exposure.

@dohernandez dohernandez merged commit e616b33 into main Jul 30, 2025
6 checks passed
@dohernandez dohernandez deleted the fix/automate-config branch July 30, 2025 16:58
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