Repository navigation
Conversation
…N list keys Handle three generic JSON/JSON_IETF decoding cases in Converter uncovered during southbound gNMI Get/Subscribe probing (#557, #504): - Treat empty, whitespace-only, and literal null JSON payloads as absent/no-op on containers, fields, and nested container members instead of failing with io.EOF, panicking on nil reflect.Type, or passing nil into sdcpb.ConvertJsonValueToTv (while preserving [null] on empty leaves and EmptyVal on child presence containers whose members are all null/state). - Accept list keys present in both upd.Path and the JSON object when their normalized values agree (including bare and module-qualified JSON key names and identityref / leafref-to-identityref module qualifiers), while still erroring when values or explicit qualifiers disagree. Signed-off-by: Markus Vahlenkamp <markus.vahlenkamp@nokia.com>
…qualifiers - Drop JSON null elements inside leaf-list arrays instead of emitting "<nil>". - Treat empty, whitespace-only and null JSON on top-level leaf-list paths as no-op, matching container and field paths. - Only reject identityref key qualifiers when the identity is present in the schema prefix maps; qualifiers on unknown identities are stripped as before. Signed-off-by: Markus Vahlenkamp <markus.vahlenkamp@nokia.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
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.
Summary
Fixes three standalone
JSON/JSON_IETFhandling bugs inpkg/utils/converter.go(uncovered via live gNMIGet/Subscribeprobe responses in #557):JSON
null(json_val: "null"/json_ietf_val: "null"and nestednullmembers):Decode(&v)yieldedv == nil, causingExpandContainerValueto hitreflect.TypeOf(jv).String()and panic onnil, whileSchemaElem_Fieldpassednilintosdcpb.ConvertJsonValueToTv(panicking ondecimal64, fabricating"<nil>"onenumeration/bits, and silently fabricating0/falseon numeric/boolean leaves).type emptyis[null], while barenullrepresents an absent member) and gNMI § 2.3.1, decodednilis now treated as absent/no-op on top-level containers, top-level fields, and known nested members, while preserving[null]foremptyleaves andEmptyValfor child presence containers whose JSON object contains onlynull/state children. Also replacesreflect.TypeOf(...).String()/.Name()with nil-safe%T.Empty or whitespace-only JSON payloads (
json_val: ""):json_val/json_ietf_valpreviously failedjson.Decoder.Decodewithio.EOF(causingGetSync/StreamSyncto drop the notification) or leaked an unexpandedTypedValuewhenJsonValwasnilon a field path.decodeJSONValuenow treats empty/whitespace-only JSON byte slices as an empty update (nil, nil).List keys present in both
upd.Pathand the JSON object:Geton a keyed list entry (gNMI §§ 2.2.2 & 2.3.1, RFC 7950 § 7.8.2, RFC 7951 § 5.4) carries the key inPathElem.keyand repeats the key leaf inside the serialized JSON entry object.ExpandContainerValuepreviously rejected any overlap unconditionally (key %q is present in both the path and JSON value).resolveListKeyreconciles bare (<key>), RFC 7951 module-qualified (<module>:<key>), and path-supplied keys—stripping valid module/prefix qualifiers on both directidentityrefandleafref-to-identityrefkeys—accepting matching normalized values and returning an error when values or explicit qualifiers conflict.Testing
pkg/utils/converter_test.gocovering container/field/nestednull, RFC 7951[null]onempty, child presence containers withnullchildren,nil/empty/whitespacejson_val&json_ietf_val, matching vs. conflicting path+JSON list keys (array, object, andleafref→identityrefmodule qualifiers), and multi-updateExpandUpdatesbatches.go test -race ./...golangci-lint run ./pkg/utils/...