AdGuard config edits: enforce python+yaml, never sed #17

Open
opened 2026-05-27 05:56:51 +00:00 by fkrebs · 0 comments
Owner

Problem

sed-style newline insertion into AdGuard's YAML config crashed AdGuard on 2026-05-26. AdGuard's config file is sensitive to formatting and sed with multi-line patterns is fragile.

Action

  • Document rule in /docs/services/adguard-dns.md: always use python3 + PyYAML or yq for config edits
  • Check if there's any existing automation (cron, n8n, scripts) that edits AdGuard config via sed — replace if found
  • Consider a pre-edit backup step: cp adguardhome.yaml adguardhome.yaml.bak before any programmatic edit

Rule

# Never:
sed -i '/key:/a\  - new_item' adguardhome.yaml

# Always:
python3 -c "import yaml; c=yaml.safe_load(open('adguardhome.yaml')); ...; yaml.dump(c, open('adguardhome.yaml','w'))"
# or:
yq -i '.key += ["new_item"]' adguardhome.yaml
## Problem `sed`-style newline insertion into AdGuard's YAML config crashed AdGuard on 2026-05-26. AdGuard's config file is sensitive to formatting and sed with multi-line patterns is fragile. ## Action - [ ] Document rule in `/docs/services/adguard-dns.md`: always use `python3 + PyYAML` or `yq` for config edits - [ ] Check if there's any existing automation (cron, n8n, scripts) that edits AdGuard config via sed — replace if found - [ ] Consider a pre-edit backup step: `cp adguardhome.yaml adguardhome.yaml.bak` before any programmatic edit ## Rule ```bash # Never: sed -i '/key:/a\ - new_item' adguardhome.yaml # Always: python3 -c "import yaml; c=yaml.safe_load(open('adguardhome.yaml')); ...; yaml.dump(c, open('adguardhome.yaml','w'))" # or: yq -i '.key += ["new_item"]' adguardhome.yaml ```
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: fkrebs/docs#17