Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 17, 2025

Fix for Watch.Response Raw Data Preservation

  • Understand the issue: Watch.Response with type ADDED (and all types) doesn't properly deserialize DynamicKubernetesObject's raw field
  • Create test to reproduce the issue
  • Identify root cause: Watch.parseLine was using JSON.deserialize() static method which uses the global static GSON instance instead of the ApiClient-specific GSON instance that has DynamicKubernetesTypeAdaptorFactory registered
  • Fix Watch.parseLine to use proper GSON deserialization via json.getGson().fromJson()
  • Verify fix with test - all tests pass
  • Run all existing tests to ensure no regression - 287 tests in util module pass
  • Run DynamicKubernetesApi tests - 7 tests pass
  • Run GenericKubernetesApi tests - 14 tests pass
  • Code review - No issues found
  • Security scan - No security vulnerabilities detected
  • Fix code formatting issues - Split long lines, add proper imports, fix trailing whitespace

Summary

Issue: Watch.Response objects were not properly deserializing DynamicKubernetesObject's raw JSON data for any event type (ADDED, MODIFIED, DELETED, etc.).

Root Cause: The Watch.parseLine() method was using JSON.deserialize() static methods which use the global static GSON instance, not the ApiClient-specific GSON instance that has DynamicKubernetesTypeAdaptorFactory registered.

Fix: Changed Watch.parseLine() to use json.getGson().fromJson() directly, ensuring it uses the properly configured GSON instance with custom TypeAdapters. This is a minimal 2-line change that fixes the issue for all Watch.Response types.

Formatting Fixes:

  • Added proper import for DynamicKubernetesTypeAdaptorFactory
  • Split long lines (>100 chars) to comply with code style guidelines
  • Moved inline comments to separate lines
  • Fixed trailing whitespace

Testing:

  • Added comprehensive tests for DynamicKubernetesObject with Watch
  • Verified both ADDED and MODIFIED events properly preserve raw JSON data
  • All tests pass after formatting changes

Security: No vulnerabilities detected by CodeQL scan.

Original prompt

This section details on the original issue you should resolve

<issue_title>Watch.Response with type ADDED does not provide object's data</issue_title>
<issue_description>Describe the bug

If the response received from calling GenericKubernetesApi.watch has type "ADDED", the KubernetesObject in object has only metadata. raw is empty (null). (The object's raw data is provided for type "MODIFIED")

Client Version
v19

Java Version
Java 17

To Reproduce
Call the method, add a Kubernetes object, look at the result.

Expected behavior
The (raw) data should be provided.
</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 17, 2025
…n issue

Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Copilot
Once this PR has been reviewed and has the lgtm label, please ask for approval from brendandburns. For more information see the Code Review Process.

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

Details 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

1 similar comment
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Copilot
Once this PR has been reviewed and has the lgtm label, please ask for approval from brendandburns. For more information see the Code Review Process.

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

Details 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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 17, 2025
Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Watch.Response for ADDED type to return object's data Fix Watch.Response deserialization to preserve DynamicKubernetesObject raw data Nov 17, 2025
Copilot AI requested a review from brendandburns November 17, 2025 23:08
@brendandburns
Copy link
Contributor

@copilot please fix style formatting errors. Thanks

Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 27, 2026

@copilot please fix style formatting errors. Thanks

Fixed in commit fcc8282. Split long lines (>100 chars), added proper import for DynamicKubernetesTypeAdaptorFactory, moved inline comments to separate lines, and fixed trailing whitespace.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://storage.googleapis.com/art-groovy-filestore-1478119448/filestore/ec/ec0cff972779969aff4e8e40e5633dbd59d49ebc
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -classpath /home/REDACTED/work/java/java/.mvn/wrapper/maven-wrapper.jar -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/java/java org.apache.maven.wrapper.MavenWrapperMain spotless:check (http block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -classpath /home/REDACTED/work/java/java/.mvn/wrapper/maven-wrapper.jar -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/java/java org.apache.maven.wrapper.MavenWrapperMain spotless:apply -pl util (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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.

Watch.Response with type ADDED does not provide object's data

3 participants