You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both GUIs store the DHCPv6 prefix delegation size in <dhcp6-ia-pd-len> as a bit count from 0 to 16 or as none. Interface.DHCP6IaPdLen was a strict int in pkg/schema/opnsense and pkg/schema/pfsense, so none raised a strconv error that ended the decode of the whole config, and convert, display, audit, validate and diff exited 1 with no report. Both vendors were affected. This PR makes the field a string in both schemas.
none requests no prefix delegation at all; it is not a missing size hint. Both vendors' interfaces.inc gate the prefix delegation request on is_numeric(): OPNsense 26.7.9 at L2932 and L2981, pfSense at L5030 and L5052. OPNsense offers none beside the bit counts (interfaces.php L1731-1752, NetworkInterface.xml L149-172). pfSense lists it first (interfaces.php L2814, the same in RELENG_2_7_2 L2504) and preselects it when a DHCPv6 interface has no value (L305-306), so saving such an interface without picking a size writes it.
Nothing outside pkg/schema reads the field, so no converter, validator or pkg/model change is needed, and convert output for every config fixture under testdata/ is unchanged. The value is kept as written and is still not mapped into CommonDevice. #834 tracks that, so until it lands diff reports nothing for a change from 0 to none.
A string also keeps <dhcp6-ia-pd-len>0</dhcp6-ia-pd-len> when the schema struct is marshaled. The int with omitempty dropped it, and an absent element fails the same is_numeric() test, so the marshaled config requested no prefix delegation where the original requested it.
Type of Change
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to not work as expected)
Documentation update (changes to documentation only)
Refactoring (no functional changes, code improvements)
Performance improvement (improves performance without changing functionality)
Test addition/update (adding or updating tests)
Build/CI change (changes to build system or CI configuration)
Code Quality: golangci-lint run ./pkg/schema/... ./pkg/parser/... reports 0 issues, formatters included
Linting: as above
Tests: go test ./pkg/schema/... ./pkg/parser/... ./internal/cfgparser/... ./internal/validator/... passes
Error Handling: not applicable, no error path changes
Logging: not applicable
Documentation: the schema doc comments, GOTCHAS 15.0, the API snapshots and the model reference row are updated
Dependencies: none added or changed
Security: no secrets or credentials involved
Input Validation: not applicable
Test Commands Executed
go test ./pkg/schema/... ./pkg/parser/... ./internal/cfgparser/... ./internal/validator/...
golangci-lint run ./pkg/schema/... ./pkg/parser/...
go test ./pkg/parser -run TestPublicAPISnapshot -update
pre-commit run --files docs/templates/model-reference.md GOTCHAS.md
Test Results
The same inputs through opndossier-main, built from main, and opndossier, built from this branch, each with go build -o <name> .. The inputs are two shipped fixtures with their one <dhcp6-ia-pd-len>0</dhcp6-ia-pd-len> changed to none:
sed 's|<dhcp6-ia-pd-len>0</dhcp6-ia-pd-len>|<dhcp6-ia-pd-len>none</dhcp6-ia-pd-len>|' testdata/config.xml.sample > pdlen-none.xml
sed 's|<dhcp6-ia-pd-len>0</dhcp6-ia-pd-len>|<dhcp6-ia-pd-len>none</dhcp6-ia-pd-len>|' testdata/pfsense/config-pfSense.xml > pf-pdlen-none.xml
forbinin ./opndossier-main ./opndossier;doecho"== $bin"forfin pdlen-none.xml pf-pdlen-none.xml;doforcmdin"convert --format json""display""validate""audit --mode blue --format json""audit --mode red --format json";do$bin$cmd"$f"> /dev/null 2>&1;echo"$f$cmd: exit=$?";done;done$bin diff testdata/config.xml.sample pdlen-none.xml;echo"diff exit=$?"$bin diff testdata/pfsense/config-pfSense.xml pf-pdlen-none.xml;echo"diff exit=$?"done
Check
main
This PR
The loop, all ten lines
exit=1
exit=0
diff, both vendors
exit 1, Failed to parse new config
exit 0, No changes detected between configurations.
On this branch each none file converts to the same JSON as its unmodified fixture:
With the two schema files reverted and the new tests kept, the tests fail on both vendors. 0a3f0fe4 is this PR's base:
git checkout 0a3f0fe4 -- pkg/schema/opnsense/interfaces.go pkg/schema/pfsense/interfaces.go
go test ./pkg/schema/opnsense ./pkg/schema/pfsense ./pkg/parser/opnsense ./pkg/parser/pfsense -run DHCP6IaPdLen -v
git checkout HEAD -- pkg/schema/opnsense/interfaces.go pkg/schema/pfsense/interfaces.go
TestParser_DHCP6IaPdLen_EndToEnd, in both parser packages, fails on the none cases in both validate modes with the strconv error and passes on every bit count from 0 to 16, the empty element and the absent element.
TestInterfaces_DHCP6IaPdLen_DecodesEveryGUIValue, in both schema packages, fails on every case: none with the strconv error, and the rest because the field decodes to an int where the test expects the string as written. 0 also fails because the marshal drops <dhcp6-ia-pd-len>0</dhcp6-ia-pd-len>.
Interface.DHCP6IaPdLen is a string in both schemas, with the tags and column alignment unchanged. Each Interface doc comment says why.
The schema tests decode an <interfaces> block with the value on the second of three interfaces, for none, every bit count from 0 to 16, an empty element and an absent element, and marshal it back.
The end-to-end tests drive a config with a DHCPv6 WAN and a track6 LAN through parser.Factory.CreateDevice in both validate modes, for the same values, and check that both interfaces and a filter rule after <interfaces> are converted. They do not check the stored value, which is not mapped into CommonDevice.
GOTCHAS 15.0 gains a paragraph on why a strict int failed the whole parse.
Review Checklist
For Reviewers
Code Quality: Code follows project conventions and Go standards
Architecture: Changes align with project architecture patterns
None of the above. GOTCHAS 15.0, the two Interface doc comments, the API snapshots and the DHCP6IaPdLen row of docs/templates/model-reference.md are updated.
API Changes
Interface.DHCP6IaPdLen in pkg/schema/opnsense and pkg/schema/pfsense changes from int to string, so its JSON and YAML key dhcp6IaPdLen holds a string instead of a number. docs/development/public-api.md treats pkg/schema/* as vendor-tracking, so this follows the vendors rather than making a semver commitment. pkg/model does not change.
Breaking Changes
None in pkg/model or in CLI output. A pkg/schema caller that read DHCP6IaPdLen as an int will need to read a string: "0" to "16", "none", or "" for an empty or absent element. Released versions through v1.10.0 expose the field as an int.
Migration Guide
None needed for the model or the CLI. A pkg/schema caller can use strconv.Atoi on the string and treat a failure as no prefix delegation, as the vendors' is_numeric() test does.
Security Considerations
None. The field holds no secret.
Performance Impact
None.
Acceptance Criteria
A config with <dhcp6-ia-pd-len>none</dhcp6-ia-pd-len> parses on both vendors, and convert, display, audit, validate and diff complete
0, 16, an empty element and an absent element still decode
convert output for every config fixture under testdata/ is unchanged
The new tests fail on main's schema types for both vendors
Additional Notes
The shipped fixtures that carry the element all hold 0, which is why no test caught this.
go run tools/docgen/main.go also refreshes rows of docs/templates/model-reference.md that earlier changes left stale: Floating, Quick and Disabled in the OPNsense filter rule table (now *string) and a DisableFilter row in the system table. Those changes are unrelated to this fix and are left out.
Labels
bug-fix
AI disclosure
Used Claude Code (claude-opus-5-5) to trace the vendor source and write the change, the tests and this description. All changes reviewed locally before push. Followed process per AI_POLICY.md.
Both GUIs store the DHCPv6 prefix delegation size in <dhcp6-ia-pd-len>
as a bit count from 0 to 16 or as "none", which requests no prefix
delegation at all. OPNsense 26.7.9 offers none beside the bit counts
(interfaces.php L1731-1752). pfSense lists it first and selects it when
a DHCPv6 interface has no value (interfaces.php L305-306, L2814). Both
interfaces.inc files gate the prefix delegation request on is_numeric().
Interface.DHCP6IaPdLen was a strict int in both schemas, so "none"
raised a strconv error that failed the parse of the whole config, and
convert, display, audit, validate and diff exited 1 with no report. The
field is now a string in pkg/schema/opnsense and pkg/schema/pfsense.
Nothing outside pkg/schema reads it, so no converter, validator or
model change is needed, and convert output for every testdata fixture is
unchanged. A string also keeps <dhcp6-ia-pd-len>0</dhcp6-ia-pd-len> on
marshal, which the int with omitempty dropped.
The tests decode every size the GUIs offer through the schema and the
parsers. The API snapshots, the model reference row and GOTCHAS 15.0
are updated.
Signed-off-by: intigenesis <313311150+intigenesis@users.noreply.github.com>
No actionable comments were generated in the recent review.
Summary by CodeRabbit
Bug Fixes
Fixed configuration parsing for DHCPv6 prefix-delegation lengths in OPNsense and pfSense. Values such as none, empty or missing entries, and numeric lengths from 0 to 16 are now handled without causing the configuration decode to fail.
Preserved prefix-delegation values when reading and writing configuration files, including nonnumeric values such as none.
Walkthrough
Both OPNsense and pfSense now represent DHCPv6 prefix-delegation length as a string. Schema round-trip tests and end-to-end parser tests cover none, empty and absent elements, and numeric values from 0 to 16.
Changes
DHCPv6 Prefix-Length Parsing
Layer / File(s)
Summary
String schema contract and XML round-trip coverage pkg/schema/opnsense/interfaces.go, pkg/schema/pfsense/interfaces.go, pkg/schema/opnsense/interface_dhcp6_pd_len_test.go, pkg/schema/pfsense/interface_dhcp6_pd_len_test.go, pkg/parser/testdata/api-snapshots/*, docs/templates/model-reference.md, GOTCHAS.md
Both schema fields change from int to string; their serialization tags remain unchanged. Schema tests cover decoding and marshal-round-trip behavior for GUI values. API snapshots and documentation describe the field and its values.
Parser tests cover none, empty and absent elements, and values from 0 to 16 with validation enabled and disabled. They check device creation, WAN and LAN interfaces, and firewall rules.
This change lets configurations with a "none" DHCPv6 prefix-delegation length parse in both OPNsense and pfSense. Tests cover the affected values. Library callers that read the field must now handle a string instead of an int. The merge risk is minimal.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title "fix(parser): accept prefix delegation size none on DHCPv6 interfaces" follows the conventional commit format (type fix, scope parser, description). It matches the main change: the DHCP6IaPd…
Description check
The description covers the problem, the fix, the vendor evidence, and the test results. It follows the template's main sections, including Description, Type of Change, Related Issues, Testing, Changes…
Linked Issues check
[#1071] Requirement: a config with none must parse on OPNsense and pfSense, and the commands must not exit on a parse error. The head diff changes Interface.DHCP6IaP…
Out of Scope Changes check
The whole-PR changes against merge base 0a3f0fe are: the two schema field type changes with doc comments, new schema and parser regression tests, API snapshot golden updates for the changed field, a …
Go Exported-Symbol Godoc
The check applies to exported identifiers in non-test production .go files. The PR's changed .go files are pkg/schema/opnsense/interfaces.go and pkg/schema/pfsense/interfaces.go (modified), plus sever…
Full details: Title check
Explanation
The title "fix(parser): accept prefix delegation size none on DHCPv6 interfaces" follows the conventional commit format (type fix, scope parser, description). It matches the main change: the DHCP6IaPdLen field changes from int to string so that the value none parses in both the OPNsense and pfSense schemas.
Full details: Description check
Explanation
The description covers the problem, the fix, the vendor evidence, and the test results. It follows the template's main sections, including Description, Type of Change, Related Issues, Testing, Changes Made, Documentation, API Changes, Breaking Changes, and Acceptance Criteria. Some template items remain unchecked or unfilled, such as the Review Checklist, the Documentation checklist, and the Performance and Security sections. These gaps are non-critical, since the description is mostly complete.
Full details: Linked Issues check
Explanation
[#1071] Requirement: a config with <dhcp6-ia-pd-len>none</dhcp6-ia-pd-len> must parse on OPNsense and pfSense, and the commands must not exit on a parse error. The head diff changes Interface.DHCP6IaPdLen from int to string in pkg/schema/opnsense/interfaces.go and pkg/schema/pfsense/interfaces.go. The XML tag is unchanged, so encoding/xml no longer calls strconv on the element body. This removes the strconv error that ended the decode. The 0-16 values, the empty element and the absent element are all valid strings, so they still decode. A non-empty string such as "0" survives marshal under omitempty, which meets the marshal-preservation requirement. The new tests in pkg/schema//interface_dhcp6_pd_len_test.go and pkg/parser//converter_dhcp6_pd_len_test.go cover these values, per the PR description. I did not run these tests. Related #834 is a separate mapping task and is not a requirement of #1071.
Full details: Out of Scope Changes check
Explanation
The whole-PR changes against merge base 0a3f0fe are: the two schema field type changes with doc comments, new schema and parser regression tests, API snapshot golden updates for the changed field, a model-reference doc row for the field, and a GOTCHAS 15.0 paragraph. Each supports the #1071 fix or documents it. The PR description states that unrelated stale rows in docs/templates/model-reference.md were regenerated but left out. No converter, validator, or pkg/model change is present in the PR description's file list. The claim that convert output is byte-identical for the 19 fixtures is author-reported evidence; I did not re-run it.
Full details: Go Exported-Symbol Godoc
Explanation
The check applies to exported identifiers in non-test production .go files. The PR's changed .go files are pkg/schema/opnsense/interfaces.go and pkg/schema/pfsense/interfaces.go (modified), plus several new *_test.go files (exempt). The other changed files are GOTCHAS.md, a markdown doc, and .golden snapshots, which are not Go source. The diff for the two production files adds no new exported identifier. It changes only the type of the existing exported field DHCP6IaPdLen from int to string and adds prose to the existing Interface type doc comments. Struct fields are outside the listed identifier kinds (functions, methods, types, constants, variables). The Interface type comments already start with the identifier name: "Interface represents a single network interface..." (opnsense) and "Interface represents a pfSense network interface..." (pfsense). Both directly precede the declaration with no blank line. No qualifying identifier lacks a conforming doc comment, so there are no hits to report.
Finishing Touches
Simplify code
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
A length may arrive as none Or numbers in the GUI’s range The schemas keep the value as text Round trips check what XML exchanged Two parsers read the tested cases
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.
Queue this pull request once it meets the queue conditions
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
breaking_changeSignificant changes that disrupt backward compatibility.goPull requests that update go codetestingTest infrastructure and test-related issuestype:bugBug or defect that needs fixing
1 participant
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.
Pull Request
Description
Both GUIs store the DHCPv6 prefix delegation size in
<dhcp6-ia-pd-len>as a bit count from 0 to 16 or asnone.Interface.DHCP6IaPdLenwas a strictintinpkg/schema/opnsenseandpkg/schema/pfsense, sononeraised astrconverror that ended the decode of the whole config, andconvert,display,audit,validateanddiffexited 1 with no report. Both vendors were affected. This PR makes the field astringin both schemas.nonerequests no prefix delegation at all; it is not a missing size hint. Both vendors'interfaces.incgate the prefix delegation request onis_numeric(): OPNsense 26.7.9 at L2932 and L2981, pfSense at L5030 and L5052. OPNsense offersnonebeside the bit counts (interfaces.phpL1731-1752,NetworkInterface.xmlL149-172). pfSense lists it first (interfaces.phpL2814, the same in RELENG_2_7_2 L2504) and preselects it when a DHCPv6 interface has no value (L305-306), so saving such an interface without picking a size writes it.Nothing outside
pkg/schemareads the field, so no converter, validator orpkg/modelchange is needed, andconvertoutput for every config fixture undertestdata/is unchanged. The value is kept as written and is still not mapped intoCommonDevice. #834 tracks that, so until it landsdiffreports nothing for a change from0tonone.A string also keeps
<dhcp6-ia-pd-len>0</dhcp6-ia-pd-len>when the schema struct is marshaled. Theintwithomitemptydropped it, and an absent element fails the sameis_numeric()test, so the marshaled config requested no prefix delegation where the original requested it.Type of Change
Related Issues
intno longer holds.Testing
Pre-submission Checklist
golangci-lint run ./pkg/schema/... ./pkg/parser/...reports 0 issues, formatters includedgo test ./pkg/schema/... ./pkg/parser/... ./internal/cfgparser/... ./internal/validator/...passesTest Commands Executed
Test Results
The same inputs through
opndossier-main, built frommain, andopndossier, built from this branch, each withgo build -o <name> .. The inputs are two shipped fixtures with their one<dhcp6-ia-pd-len>0</dhcp6-ia-pd-len>changed tonone:mainexit=1exit=0diff, both vendorsFailed to parse new configNo changes detected between configurations.On this branch each
nonefile converts to the same JSON as its unmodified fixture:Both lines print.
convertoutput for all 19 config fixtures undertestdata/is byte-identical between the two binaries; this loop prints nothing:With the two schema files reverted and the new tests kept, the tests fail on both vendors.
0a3f0fe4is this PR's base:git checkout 0a3f0fe4 -- pkg/schema/opnsense/interfaces.go pkg/schema/pfsense/interfaces.go go test ./pkg/schema/opnsense ./pkg/schema/pfsense ./pkg/parser/opnsense ./pkg/parser/pfsense -run DHCP6IaPdLen -v git checkout HEAD -- pkg/schema/opnsense/interfaces.go pkg/schema/pfsense/interfaces.goTestParser_DHCP6IaPdLen_EndToEnd, in both parser packages, fails on thenonecases in both validate modes with thestrconverror and passes on every bit count from0to16, the empty element and the absent element.TestInterfaces_DHCP6IaPdLen_DecodesEveryGUIValue, in both schema packages, fails on every case:nonewith thestrconverror, and the rest because the field decodes to anintwhere the test expects the string as written.0also fails because the marshal drops<dhcp6-ia-pd-len>0</dhcp6-ia-pd-len>.Changes Made
Files Modified
pkg/schema/opnsense/interfaces.go,pkg/schema/pfsense/interfaces.gopkg/schema/opnsense/interface_dhcp6_pd_len_test.go,pkg/schema/pfsense/interface_dhcp6_pd_len_test.go(new)pkg/parser/opnsense/converter_dhcp6_pd_len_test.go,pkg/parser/pfsense/converter_dhcp6_pd_len_test.go(new)pkg/parser/testdata/api-snapshots/pkg-schema-opnsense.golden,pkg-schema-pfsense.goldendocs/templates/model-reference.mdGOTCHAS.mdKey Changes
Interface.DHCP6IaPdLenis astringin both schemas, with the tags and column alignment unchanged. EachInterfacedoc comment says why.<interfaces>block with the value on the second of three interfaces, fornone, every bit count from0to16, an empty element and an absent element, and marshal it back.parser.Factory.CreateDevicein both validate modes, for the same values, and check that both interfaces and a filter rule after<interfaces>are converted. They do not check the stored value, which is not mapped intoCommonDevice.intfailed the whole parse.Review Checklist
For Reviewers
For Contributors
feat/,fix/,docs/, etc.)Documentation
Documentation Updates
None of the above. GOTCHAS 15.0, the two
Interfacedoc comments, the API snapshots and theDHCP6IaPdLenrow ofdocs/templates/model-reference.mdare updated.API Changes
Interface.DHCP6IaPdLeninpkg/schema/opnsenseandpkg/schema/pfsensechanges frominttostring, so its JSON and YAML keydhcp6IaPdLenholds a string instead of a number.docs/development/public-api.mdtreatspkg/schema/*as vendor-tracking, so this follows the vendors rather than making a semver commitment.pkg/modeldoes not change.Breaking Changes
None in
pkg/modelor in CLI output. Apkg/schemacaller that readDHCP6IaPdLenas anintwill need to read a string:"0"to"16","none", or""for an empty or absent element. Released versions through v1.10.0 expose the field as anint.Migration Guide
None needed for the model or the CLI. A
pkg/schemacaller can usestrconv.Atoion the string and treat a failure as no prefix delegation, as the vendors'is_numeric()test does.Security Considerations
None. The field holds no secret.
Performance Impact
None.
Acceptance Criteria
<dhcp6-ia-pd-len>none</dhcp6-ia-pd-len>parses on both vendors, andconvert,display,audit,validateanddiffcomplete0,16, an empty element and an absent element still decodeconvertoutput for every config fixture undertestdata/is unchangedmain's schema types for both vendorsAdditional Notes
The shipped fixtures that carry the element all hold
0, which is why no test caught this.go run tools/docgen/main.goalso refreshes rows ofdocs/templates/model-reference.mdthat earlier changes left stale:Floating,QuickandDisabledin the OPNsense filter rule table (now*string) and aDisableFilterrow in the system table. Those changes are unrelated to this fix and are left out.Labels
bug-fixAI disclosure
Used Claude Code (
claude-opus-5-5) to trace the vendor source and write the change, the tests and this description. All changes reviewed locally before push. Followed process perAI_POLICY.md.By submitting this pull request, I confirm that: