tien / pi-hole-connect

Unofficial Android client for Pi-hole®
https://play.google.com/store/apps/details?id=com.tien.piholeconnect
GNU General Public License v3.0
50 stars 4 forks source link

[BUG] Statistics page blank and throws error when 0 queries blocked #202

Open rmbleeker opened 6 months ago

rmbleeker commented 6 months ago

Describe the bug The statistics page is blank and at the bottom an error pops up telling me to check my internet connection (which is fine) or that the API key has been set properly (it has). I suspect the cause of the error is instead a bug in the JSON parser in the app, or some of the returned JSON code is not properly quoted/escaped.

To Reproduce Steps to reproduce the behaviour:

  1. Have a working Pi-Hole with 0 queries blocked and a 0,00% block percentage on the Home page
  2. Click on Statistics
  3. See blank page with error

Expected behaviour I would expect to see the normal statistics page with the "Top permitted", "Top blocked" and "Top client" sections, only the "Top blocked" section should probably be empty since there are no sites blocked by this Pi-Hole unit yet.

Screenshots

Smartphone (please complete the following information):

Additional context I have a setup where I run 2 Raspberry Pi 4's each with Pi-Hole and Unbound, in order to have a fallback DNS server in case the first one stops working. The secondary Pi-Hole is rarely used and often has not have to block any DNS queries. The primary Pi-Hole rarely has an empty "queries blocked" list, maybe right after a reboot, so I have not seen the described behaviour there.

Error message

lb.f: Illegal input: Unexpected JSON token at offset 262: Expected start of the object '{', but had ':' instead at path: $.top_ads
JSON input: .....92.in-addr.arpa":48},"top_ads":[],"top_sources":{"192.168.1......
    at mb.i.a(SourceFile:355)
    at lb.b.emit(SourceFile:163)
    at s4.v.collect(SourceFile:191)
    at lb.c.collect(SourceFile:48)
    at v6.tb.l(SourceFile:73)
    at v6.sd.m(SourceFile:82)
    at db.g.b(SourceFile:246)
    at va.a.invokeSuspend(SourceFile:365)
    at va.a.invoke(SourceFile:72)
    at rb.k.f(SourceFile:36)
    at rb.k.c(SourceFile:28)
    at va.c.invokeSuspend(SourceFile:175)
    at va.c.invoke(SourceFile:41)
    at rb.k.f(SourceFile:36)
    at rb.k.c(SourceFile:28)
    at rb.k.d(SourceFile:8)
    at bb.n.invokeSuspend(SourceFile:134)
    at bb.n.invoke(SourceFile:47)
    at rb.k.f(SourceFile:36)
    at rb.k.c(SourceFile:28)
    at rb.k.a(SourceFile:24)
    at rb.d.a(SourceFile:196)
    at wa.c.a(SourceFile:178)
    at com.tien.piholeconnect.repository.PiHoleRepositoryImpl$getStatistics$2.invokeSuspend(SourceFile:126)
    at fc.a.resumeWith(SourceFile:9)
    at cf.l0.run(SourceFile:113)
    at k.j.run(SourceFile:17)
    at jf.i.run(SourceFile:3)
    at jf.a.run(SourceFile:92)
Caused by: qf.p: Unexpected JSON token at offset 262: Expected start of the object '{', but had ':' instead at path: $.top_ads
JSON input: .....92.in-addr.arpa":48},"top_ads":[],"top_sources":{"192.168.1......
    at v6.qb.e(SourceFile:33)
    at v6.qb.d(SourceFile:35)
    at qf.a.s(SourceFile:59)
    at qf.a.t(SourceFile:13)
    at qf.a.u(SourceFile:113)
    at qf.a.D(SourceFile:42)
    at qf.h0.j(SourceFile:47)
    at qf.e0.b(SourceFile:45)
    at of.a.e(SourceFile:18)
    at of.a.deserialize(SourceFile:6)
    at qf.e0.z(SourceFile:69)
    at v6.vb.w(SourceFile:11)
    at qf.e0.w(SourceFile:49)
    at com.tien.piholeconnect.model.PiHoleStatistics$$serializer.deserialize(SourceFile:1)
    at com.tien.piholeconnect.model.PiHoleStatistics$$serializer.deserialize(SourceFile:2)
    at qf.e0.z(SourceFile:69)
    at mb.i.a(SourceFile:230)
    ... 28 more