Skip to content

Conversation

@Gold856
Copy link
Collaborator

@Gold856 Gold856 commented Dec 9, 2025

Description

#2224 removed the custom deserializers for Path, but we still need one to be able to deserialize the Path key in NeuralNetworkPropertyManager. Additionally, Jackson seems to auto-convert the Path key to a String using toString instead of its own serializers, so a custom key serializer is also needed to consistently use the same format for paths. This also removes unused serde methods in JacksonUtils to minimize potential future churn, and tacks an @JsonIgnore on getModels to prevent Jackson from serializing a ModelProperty array into the database.

Meta

Merge checklist:

  • Pull Request title is short, imperative summary of proposed changes
  • The description documents the what and why
  • If this PR changes behavior or adds a feature, user documentation is updated
  • If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly
  • If this PR touches configuration, this is backwards compatible with settings back to v2025.3.2
  • If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated
  • If this PR addresses a bug, a regression test for it is added

@Gold856 Gold856 requested a review from a team as a code owner December 9, 2025 07:23
@github-actions github-actions bot added the backend Things relating to photon-core and photon-server label Dec 9, 2025
@Gold856 Gold856 force-pushed the fix-jackson-serialization branch from eeb1010 to 9eebc24 Compare December 9, 2025 08:07
@Gold856
Copy link
Collaborator Author

Gold856 commented Dec 9, 2025

Implemented a test that, on main, will fail:

NeuralNetworkPropertyManagerTest > testSerialization() FAILED
    org.opentest4j.AssertionFailedError: Unexpected exception thrown: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot find a (Map) Key deserializer for type [simple type, class java.nio.file.Path]
     at [Source: (String)"{
      "models" : [ {
        "modelPath" : "file:///D:/photonvision/test/yolov8nCOCO.rknn",
        "nickname" : "COCO",
        "labels" : [ ],
        "resolutionWidth" : 640,
        "resolutionHeight" : 640,
        "family" : "RKNN",
        "version" : "YOLOV8"
      } ],
      "modelPathToProperties" : {
        "test\\yolov8nCOCO.rknn" : {
          "modelPath" : "file:///D:/photonvision/test/yolov8nCOCO.rknn",
          "nickname" : "COCO",
          "labels" : [ ],
          "resolutionWidth" : 640,
          "resolutionHeight" : "[truncated 73 chars]; line: 1, column: 1]
        at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:152)
        at app//org.junit.jupiter.api.AssertDoesNotThrow.createAssertionFailedError(AssertDoesNotThrow.java:84)
        at app//org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:75)
        at app//org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:58)
        at app//org.junit.jupiter.api.Assertions.assertDoesNotThrow(Assertions.java:3259)
        at app//org.photonvision.common.configuration.NeuralNetworkPropertyManagerTest.testSerialization(NeuralNetworkPropertyManagerTest.java:29)

        Caused by:
        com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot find a (Map) Key deserializer for type [simple type, class java.nio.file.Path]
         at [Source: UNKNOWN; line: 1, column: 1]
            at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
            at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1915)
            at com.fasterxml.jackson.databind.deser.DeserializerCache._handleUnknownKeyDeserializer(DeserializerCache.java:603)
            at com.fasterxml.jackson.databind.deser.DeserializerCache.findKeyDeserializer(DeserializerCache.java:168)
            at com.fasterxml.jackson.databind.DeserializationContext.findKeyDeserializer(DeserializationContext.java:681)
            at com.fasterxml.jackson.databind.deser.std.MapDeserializer.createContextual(MapDeserializer.java:314)
            at com.fasterxml.jackson.databind.DeserializationContext.handlePrimaryContextualization(DeserializationContext.java:836)
            at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:550)
            at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:294)
            at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
            at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
            at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:654)
            at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:4956)
            at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4826)
            at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3772)
            at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3740)
            at org.photonvision.common.util.file.JacksonUtils.deserialize(JacksonUtils.java:94)
            at org.photonvision.common.configuration.NeuralNetworkPropertyManagerTest.lambda$testSerialization$1(NeuralNetworkPropertyManagerTest.java:30)  
            at org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:71)
            ... 3 more

@Gold856 Gold856 force-pushed the fix-jackson-serialization branch 3 times, most recently from fb059e8 to 3690a36 Compare December 9, 2025 17:28
@Gold856 Gold856 force-pushed the fix-jackson-serialization branch from 3690a36 to 8265763 Compare December 9, 2025 17:33
@Gold856 Gold856 merged commit c2433e0 into PhotonVision:main Dec 9, 2025
70 of 71 checks passed
@Gold856 Gold856 deleted the fix-jackson-serialization branch December 9, 2025 23:10
samfreund pushed a commit to samfreund/photonvision that referenced this pull request Dec 18, 2025
…Vision#2232)

## Description

PhotonVision#2224 removed the custom deserializers for `Path`, but we still need one
to be able to deserialize the `Path` key in
`NeuralNetworkPropertyManager`. Additionally, Jackson seems to
auto-convert the `Path` key to a `String` using `toString` instead of
its own serializers, so a custom key serializer is also needed to
consistently use the same format for paths. This also removes unused
serde methods in `JacksonUtils` to minimize potential future churn, and
tacks an `@JsonIgnore` on `getModels` to prevent Jackson from
serializing a `ModelProperty` array into the database.

## Meta

Merge checklist:
- [x] Pull Request title is [short, imperative
summary](https://cbea.ms/git-commit/) of proposed changes
- [x] The description documents the _what_ and _why_
- [ ] If this PR changes behavior or adds a feature, user documentation
is updated
- [ ] If this PR touches photon-serde, all messages have been
regenerated and hashes have not changed unexpectedly
- [ ] If this PR touches configuration, this is backwards compatible
with settings back to v2025.3.2
- [ ] If this PR touches pipeline settings or anything related to data
exchange, the frontend typing is updated
- [x] If this PR addresses a bug, a regression test for it is added
spacey-sooty pushed a commit to spacey-sooty/photonvision that referenced this pull request Dec 22, 2025
…Vision#2232)

## Description

PhotonVision#2224 removed the custom deserializers for `Path`, but we still need one
to be able to deserialize the `Path` key in
`NeuralNetworkPropertyManager`. Additionally, Jackson seems to
auto-convert the `Path` key to a `String` using `toString` instead of
its own serializers, so a custom key serializer is also needed to
consistently use the same format for paths. This also removes unused
serde methods in `JacksonUtils` to minimize potential future churn, and
tacks an `@JsonIgnore` on `getModels` to prevent Jackson from
serializing a `ModelProperty` array into the database.

## Meta

Merge checklist:
- [x] Pull Request title is [short, imperative
summary](https://cbea.ms/git-commit/) of proposed changes
- [x] The description documents the _what_ and _why_
- [ ] If this PR changes behavior or adds a feature, user documentation
is updated
- [ ] If this PR touches photon-serde, all messages have been
regenerated and hashes have not changed unexpectedly
- [ ] If this PR touches configuration, this is backwards compatible
with settings back to v2025.3.2
- [ ] If this PR touches pipeline settings or anything related to data
exchange, the frontend typing is updated
- [x] If this PR addresses a bug, a regression test for it is added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Things relating to photon-core and photon-server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants