Added clean API for creating anonymous sections - #26
Closed
nikitagricanuk wants to merge 5 commits into
Closed
Conversation
emitString used `>` instead of `>=`, so a pair of adjacent quotes (`''` or `""`) produced no token. The parser then expected a value but received the next `option` keyword, crashing with "expected option value, got (Option ...)". Add lexer and parser test cases for empty-string options to pin the behavior. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
corny
force-pushed
the
v2
branch
7 times, most recently
from
May 29, 2026 08:39
2d4bc6d to
4e8670c
Compare
…elector Previously, Del() only searched sections by their Name field, which is empty for anonymous sections. Passing "@type[index]" was silently ignored, so DelSection() would mark the config tainted and commit a no-op write. Fix: resolve the selector via getUnnamed() for "@"-prefixed names, then remove the section by pointer identity rather than by Name string. Add comprehensive unit tests for all deletion cases: - named section deletion (regression) - anonymous section deletion by index - index shift after removal - negative index (-1 = last) - sole anonymous section - mixed named+anonymous configs - no-op on out-of-bounds or non-existent names - full round-trip via the Tree API (GetSections → DelSection → Commit) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v2 #26 +/- ##
==========================================
+ Coverage 89.02% 89.89% +0.87%
==========================================
Files 7 7
Lines 674 831 +157
==========================================
+ Hits 600 747 +147
- Misses 65 73 +8
- Partials 9 11 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
adonespitogo
pushed a commit
to flarewifi/go-uci
that referenced
this pull request
Jul 24, 2026
config.Del (backing tree.DelSection) matched a section to remove by its
literal Name field, which is empty for an anonymous section ("config
device" with no name) — never equal to the synthetic "@type[idx]" selector
GetSections/findVlanDeviceSections-style callers pass back for such a
section. DelSection("@device[3]") therefore silently matched nothing, yet
the config was still marked tainted, so a following Commit() reported
success while leaving the section untouched on disk.
Ported from upstream digineo/go-uci commit efdff98
("Added clean API for creating anonymous sections", closes digineo#26),
which fixes this same bug but only on the v2 branch (unreleased, and
carrying an unrelated breaking Tree-interface signature change). This
cherry-picks just the Del fix onto our fork of the older, still
bool-returning API flare-server currently depends on, so it's a drop-in
replacement.
Also renames the module to github.com/flarewifi/go-uci now that this fork
is the org's own dependency going forward.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've noticed that the library lacked clean API for creating anonymous sections in uci. The only way to create such section is to set section name to empty string, but this behaviour isn't documented and hasn't been tested. I've added new AddAnonymousSection function that does this and added some tests for it.