Skip to content

Fix gNMI SET failure for union with leafref and string literals#216

Open
rakshitha-marvell wants to merge 2 commits into
sonic-net:masterfrom
rakshitha-marvell:gnmi_union_string_error
Open

Fix gNMI SET failure for union with leafref and string literals#216
rakshitha-marvell wants to merge 2 commits into
sonic-net:masterfrom
rakshitha-marvell:gnmi_union_string_error

Conversation

@rakshitha-marvell

@rakshitha-marvell rakshitha-marvell commented May 7, 2026

Copy link
Copy Markdown
Contributor

Fixes : sonic-net/sonic-gnmi#669

Problem:
gNMI SET fails for SONiC models such as PFCWD, SFLOW, and QUEUE when union types contain a combination of leafref and string literals. The validation logic incorrectly rejects valid literal values.

Root Cause:
Union validation in CVL/yparser does not correctly handle mixed union types involving leafref and literal strings. Literal values are not properly matched against union members, leading to validation failure. Right now, all string literals are ignored, only leafrefs are matched.

Fix:

  • First evaluates non-leafref union members (string pattern types)
  • Traverses typedef (der - derived type) chains to locate string patterns inherited through typedef definitions
  • Validates all string patterns using RFC7950 union/string semantics
  • Skips Redis/leafref instance validation when the value definitively matches a literal string branch
  • Falls back to leafref validation only when no literal branch match exists
    This ensures valid literal values [ such as all, CPU and GLOBAL ] are accepted while preserving existing leafref validation for real interface/port references.

Fixes : sonic-net/sonic-gnmi#669

Problem:
gNMI SET fails for SONiC models such as PFCWD, SFLOW, and QUEUE
when union types contain a combination of leafref and string literals.
The validation logic incorrectly rejects valid literal values.

Root Cause:
Union validation in CVL/yparser does not correctly handle mixed union
types involving leafref and literal strings. Literal values are not
properly matched against union members, leading to validation failure.

Fix:
- Update union handling logic in yparser to correctly validate
  literal values alongside leafref types.
- Ensure proper resolution and comparison of union members.

Signed-off-by: rakshitha-marvell <rsk@marvell.com>
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@sarabjeetsingh1509

Copy link
Copy Markdown

@ronan-nexthop Can you please review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] gNMI SET failure for SONIC PFCWD, SONIC SFLOW, and SONIC QUEUE due to incorrect validation of union types containing leafref and string literals

3 participants