Skip to content

Conversation

lalitc375
Copy link
Contributor

Add cases mentioned in #292 (comment).

This pull request adds test coverage for serialization and deserialization of field paths, focusing on correctly handling spaces and invalid escape characters.

Description

This PR addresses cases mentioned in #292 (comment). The test suite is expanded to include tests for:

  • Leading and trailing spaces: New test cases have been added to fieldpath/serialize-pe_test.go, fieldpath/serialize_test.go, and fieldpath/set_test.go to ensure that leading and trailing spaces in field names and key values are preserved during serialization and deserialization round-trips.
  • Invalid escape characters: A new test has been added to fieldpath/serialize-pe_test.go to verify that an error is correctly returned when deserializing a path element that contains an invalid JSON escape sequence.

These additions improve the robustness of the serialization and deserialization logic.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 16, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @lalitc375. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 16, 2025
@lalitc375
Copy link
Contributor Author

/assign @jpbetz @liggitt

@jpbetz
Copy link
Contributor

jpbetz commented Sep 16, 2025

Thanks!

In addtion to this, I was hoping to merge some tests where the order of map keys and the spacing between delimiters (not just within the contents of strings) is not the same was what the serializer typically outputs. This would tease out issues where a streaming deserializer is accidentally sensitive to the order of the token stream or the whtiespace between tokens.

Maybe somehow "randomize" a serialized managed field in a way that is still has the same data representation? Atypical whitespace chars and atypical usages of whitespace chars (multiple newlines, ...), randomized ordering of map entries ...

@liggitt
Copy link
Contributor

liggitt commented Sep 17, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 17, 2025
`f:`,
`f:spec`,
`f:more-complicated-string`,
`f: string-with-spaces `,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember, do field-name encodings support any escaping or unescaping we need to exercise? (special characters, newlines, backslashes, non-ascii characters, etc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that is allowed for field names, but these values can exists for map keys.

@liggitt
Copy link
Contributor

liggitt commented Sep 17, 2025

In addition to this, I was hoping to merge some tests where the order of map keys and the spacing between delimiters (not just within the contents of strings) is not the same was what the serializer typically outputs. This would tease out issues where a streaming deserializer is accidentally sensitive to the order of the token stream or the whitespace between tokens.

Big +1 to this ... this PR is a great addition, we also want to exercise correct consumption of non-normalized outputs with non-semantic whitespace before / between / after tokens, and make sure the normalized output strips that out.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 23, 2025
@lalitc375
Copy link
Contributor Author

In addtion to this, I was hoping to merge some tests where the order of map keys and the spacing between delimiters (not just within the contents of strings) is not the same was what the serializer typically outputs. This would tease out issues where a streaming deserializer is accidentally sensitive to the order of the token stream or the whtiespace between tokens.

Done

@jpbetz
Copy link
Contributor

jpbetz commented Sep 23, 2025

/lgtm
/approve

Thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 23, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jpbetz, lalitc375

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 23, 2025
@k8s-ci-robot k8s-ci-robot merged commit b88846d into kubernetes-sigs:master Sep 23, 2025
6 checks passed
@lalitc375 lalitc375 deleted the test-coverage1 branch September 24, 2025 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants