-
Notifications
You must be signed in to change notification settings - Fork 3
Fix sanitize-config.py to properly remove only admin and dev sections #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…and node.dev in YAML config
✅ Deploy Preview for genlayer-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughThe script Changes
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
remodule 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
📒 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
strippedcheck (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 enclosingnode:section.- No
admin:ordev:keys are present in the sampled YAML files, so there’s no immediate edge-case exposure.
Description
This PR fixes a critical issue in the
sanitize-config.pyscript where the regex patterns were too greedy, causing the removal of entire configuration sections beyond just theadminanddevsections. 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 likerpc,ops, and other node settings.Summary by CodeRabbit