Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeserializerException: Error parsing response body #37

Closed
Devoev opened this issue Dec 27, 2021 · 2 comments
Closed

DeserializerException: Error parsing response body #37

Devoev opened this issue Dec 27, 2021 · 2 comments

Comments

@Devoev
Copy link

Devoev commented Dec 27, 2021

I'm just calling the TestDriver.main() method and I'm getting a DeserializerException.
I have 2 Repeaters and 1 PowerLine connected to my network. My router is on the newest version.
Sometimes I get a SocketTimeoutException instead.

Full log:

> Task :Main.main()
17:02:18.534 [main] DEBUG com.github.kaklakariada.fritzbox.TestDriver - Reading config from file H:\Users\Devin\Desktop\Fritz\application.properties
17:02:18.539 [main] INFO com.github.kaklakariada.fritzbox.TestDriver - Logging in to 'https://fritz.box' with username 'fritz4764'
17:02:20.228 [main] DEBUG com.github.kaklakariada.fritzbox.FritzBoxSession - Got response 045e4ad8-01d69cc698b1bbd7335c91b806ffb51c for challenge 045e4ad8
17:02:20.612 [main] DEBUG com.github.kaklakariada.fritzbox.FritzBoxSession - Logged in with session id 0622a1303fe229f7 and rights [UserRight [name=null, access=0], UserRight [name=null, access=0], UserRight [name=null, access=0], UserRight [name=null, access=0], UserRight [name=null, access=0], UserRight [name=null, access=0], UserRight [name=null, access=0], UserRight [name=null, access=0], UserRight [name=null, access=0], UserRight [name=null, access=0], UserRight [name=null, access=0], UserRight [name=null, access=0]]
Exception in thread "main" com.github.kaklakariada.fritzbox.mapping.DeserializerException: Error parsing response body '<devicelist version="1" fwversion="7.29"></devicelist>'
	at com.github.kaklakariada.fritzbox.mapping.Deserializer.parse(Deserializer.java:59)
	at com.github.kaklakariada.fritzbox.http.HttpTemplate.parse(HttpTemplate.java:104)
	at com.github.kaklakariada.fritzbox.http.HttpTemplate.get(HttpTemplate.java:82)
	at com.github.kaklakariada.fritzbox.http.HttpTemplate.get(HttpTemplate.java:71)
	at com.github.kaklakariada.fritzbox.FritzBoxSession.getAutenticated(FritzBoxSession.java:90)
	at com.github.kaklakariada.fritzbox.HomeAutomation.executeCommand(HomeAutomation.java:57)
	at com.github.kaklakariada.fritzbox.HomeAutomation.getDeviceListInfos(HomeAutomation.java:49)
	at com.github.kaklakariada.fritzbox.TestDriver.main(TestDriver.java:51)
	at Main.main(Main.java:6)
Caused by: org.simpleframework.xml.core.ValueRequiredException: Unable to satisfy @org.simpleframework.xml.ElementList(entry="", data=false, inline=true, name="device", type=com.github.kaklakariada.fritzbox.model.homeautomation.Device.class, required=true, empty=true) on field 'devices' private java.util.List com.github.kaklakariada.fritzbox.model.homeautomation.DeviceList.devices for class com.github.kaklakariada.fritzbox.model.homeautomation.DeviceList at line 1
	at org.simpleframework.xml.core.Composite.validate(Composite.java:644)
	at org.simpleframework.xml.core.Composite.readElements(Composite.java:449)
	at org.simpleframework.xml.core.Composite.access$400(Composite.java:59)
	at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383)
	at org.simpleframework.xml.core.Composite.read(Composite.java:201)
	at org.simpleframework.xml.core.Composite.read(Composite.java:148)
	at org.simpleframework.xml.core.Traverser.read(Traverser.java:92)
	at org.simpleframework.xml.core.Persister.read(Persister.java:625)
	at org.simpleframework.xml.core.Persister.read(Persister.java:606)
	at org.simpleframework.xml.core.Persister.read(Persister.java:584)
	at org.simpleframework.xml.core.Persister.read(Persister.java:562)
	at org.simpleframework.xml.core.Persister.read(Persister.java:499)
	at org.simpleframework.xml.core.Persister.read(Persister.java:408)
	at com.github.kaklakariada.fritzbox.mapping.Deserializer.parse(Deserializer.java:55)
	... 8 more

Caused by: org.simpleframework.xml.core.ValueRequiredException: Unable to satisfy @org.simpleframework.xml.ElementList(entry="", data=false, inline=true, name="device", type=com.github.kaklakariada.fritzbox.model.homeautomation.Device.class, required=true, empty=true) on field 'devices' private java.util.List com.github.kaklakariada.fritzbox.model.homeautomation.DeviceList.devices for class com.github.kaklakariada.fritzbox.model.homeautomation.DeviceList at line 1

> Task :Main.main() FAILED

Execution failed for task ':Main.main()'.
> Process 'command 'D:/Program Files/Java/jdk-14.0.1/bin/java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. 
@TDesjardins
Copy link
Contributor

Hi @Devoev ,

this API is about Home Automation devices. Repeater and Powerline devices are not considered. So your list of devices are empty:

<devicelist version="1" fwversion="7.29"></devicelist>

This results in a DeserializerException because the devices are not optional:

https://github.com/kaklakariada/fritzbox-java-api/blob/master/src/main/java/com/github/kaklakariada/fritzbox/model/homeautomation/DeviceList.java#L35

From my point of view this should be optional to prevent the exception because empty lists are expected behaviour.

@kaklakariada I could provide a PR for this.

@kaklakariada
Copy link
Owner

@TDesjardins That would be great if you could create a PR, thanks!

Please also add a test 😁

TDesjardins added a commit to TDesjardins/fritzbox-java-api that referenced this issue Aug 9, 2022
kaklakariada added a commit that referenced this issue Aug 10, 2022
Add support of empty device lists fixes #37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants