test(adk): assert real tls_insecure_skip_verify tag in omitempty test#2199
Open
anxkhn wants to merge 1 commit into
Open
test(adk): assert real tls_insecure_skip_verify tag in omitempty test#2199anxkhn wants to merge 1 commit into
anxkhn wants to merge 1 commit into
Conversation
TestMarshalJSON_OmitemptyFields listed "tls_disable_verify" in the wantAbsent slices for the OpenAI and Anthropic cases, but no Go struct field serializes to that key: the TLS-verify field on BaseModel is tagged tls_insecure_skip_verify. Because the marshaller never emits tls_disable_verify, the absence check was vacuously true and could never fail, leaving the omitempty behavior of the TLS-verify pointer untested (tls_disable_verify is a Python-only legacy alias). Use the actual json tag tls_insecure_skip_verify so the assertion exercises the intended omitempty behavior. Verified by temporarily dropping ,omitempty from the field: the corrected test then fails (the old one still passed), and it passes again once ,omitempty is restored. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a gap in Go JSON marshaling test coverage by updating TestMarshalJSON_OmitemptyFields to assert omission of the actual TLS verification JSON key (tls_insecure_skip_verify) rather than a non-existent/legacy alias (tls_disable_verify), ensuring the test can fail when omitempty behavior regresses.
Changes:
- Update OpenAI and Anthropic
wantAbsentlists to usetls_insecure_skip_verify. - Make the
omitemptyassertion meaningful forBaseModel.TLSInsecureSkipVerify(a*booltaggedjson:"tls_insecure_skip_verify,omitempty").
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
What
TestMarshalJSON_OmitemptyFields(go/api/adk/types_test.go) checks thatzero-valued
omitemptyfields are omitted from the marshalled model JSON bylisting the expected-absent JSON keys in
wantAbsent. The OpenAI and Anthropiccases listed
"tls_disable_verify", but no Go struct field serializes to thatkey: the TLS-verify field on
BaseModelisso it marshals to
tls_insecure_skip_verify. Because the marshaller never emitstls_disable_verify,raw["tls_disable_verify"]was always absent and theassertion was vacuously true, it could never fail. As a result the
omitemptybehavior of the TLS-verify pointer was not actually covered by this test.
tls_disable_verifyis a Python-only legacy validation alias(
python/packages/kagent-adk/.../types.py, viaAliasChoices) and has neverbeen a Go json tag.
This changes the two
wantAbsententries to the real json tagtls_insecure_skip_verifyso the assertion exercises the intended omissionbehavior. No production code is touched; the
,omitemptytag is already correct,so the corrected test stays green on the current code.
Why it is correct
The sibling presence test
TestMarshalJSON_BaseModelFieldsalready asserts onraw["tls_insecure_skip_verify"], confirming that is the tag the marshalleremits and that the absent-key form was a copy/paste slip from the Python field
name.
How it was verified
Temporarily dropping
,omitemptyfromBaseModel.TLSInsecureSkipVerifymakes thecorrected test fail:
while the previous
tls_disable_verifyassertion still passed under the samebroken condition, demonstrating the old check was a no-op. Restoring
,omitemptymakes the corrected test pass again.
Local checks (module
github.com/kagent-dev/kagent/go, go 1.26):go test ./api/adk/ -run TestMarshalJSON_OmitemptyFields -v-> PASS (4/4)go test -race ./api/adk/-> PASSgofmt -l,go vet ./api/adk/,golangci-lint run ./api/adk/...-> clean / 0 issues