sonic/config_generator: use "up" for BGP_NEIGHBOR_AF admin_status#2261
Open
sonic/config_generator: use "up" for BGP_NEIGHBOR_AF admin_status#2261
Conversation
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Since
admin_statusis now constrained to "up"/"down", consider centralizing these values in a small helper or constant to avoid future drift if the schema changes again. - It may be worth scanning for any remaining hard-coded boolean-like strings in related BGP config generation paths to ensure they consistently match the new Pydantic
Literal["up", "down"]expectations.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since `admin_status` is now constrained to "up"/"down", consider centralizing these values in a small helper or constant to avoid future drift if the schema changes again.
- It may be worth scanning for any remaining hard-coded boolean-like strings in related BGP config generation paths to ensure they consistently match the new Pydantic `Literal["up", "down"]` expectations.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
_add_bgp_configurations wrote "admin_status": "true" for every BGP_NEIGHBOR_AF row it generated: ipv4_unicast, ipv6_unicast and l2vpn_evpn keys for both interfaces and port channels, plus the VLAN peer ipv4_unicast row. The schema enforced by the new Pydantic validator (BgpNeighborAfListRow.admin_status) is Literal["up", "down"], so validation rejected every generated row with "Input should be 'up' or 'down'". Same fix pattern as #2260. Replace the literal "true" with "up" at all seven BGP call sites, and centralise the schema-allowed values as ADMIN_STATUS_UP / ADMIN_STATUS_DOWN constants in sonic/constants.py so future drift fails at import time rather than at validation. Switch the remaining admin_status producers (MGMT_INTERFACE, INTERFACE incl. breakout ports, VLAN, VLAN_INTERFACE, LOOPBACK, and the PORTCHANNEL row built in sonic/interface.py) to the same constants for consistency. AI-assisted: Claude Code Signed-off-by: Christian Berendt <berendt@osism.tech>
Member
Author
|
Depends on #2258 |
osfrickler
reviewed
May 5, 2026
Member
osfrickler
left a comment
There was a problem hiding this comment.
I'm not convinced that this is a good idea, operationally it is better to stick to the values that a config save on the running switch generates, so that it is easy to spot actual config changes. If the scheme we use for verification doesn't match this, then IMO the scheme is wrong, not the generated config.
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.
_add_bgp_configurations wrote "admin_status": "true" for every BGP_NEIGHBOR_AF row it generated: ipv4_unicast, ipv6_unicast and l2vpn_evpn keys for both interfaces and port channels, plus the VLAN peer ipv4_unicast row. The schema enforced by the new Pydantic validator (BgpNeighborAfListRow.admin_status) is Literal["up", "down"], so validation rejected every generated row with "Input should be 'up' or 'down'".
Replace the literal "true" with "up" at all seven call sites. Same fix pattern as #2260, which aligned other generated values with the schema.
AI-assisted: Claude Code