fiskaly / fiskaly-sdk-java

fiskaly Cloud-TSE SDK for Java/JRE and Java/Android
MIT License
4 stars 0 forks source link

Native sdk crash when trying to query non-existing API version #34

Open ghost opened 3 years ago

ghost commented 3 years ago

When preparing for migration to Fiskaly Sign API v2, I discovered some issue with java sdk (checked with 1.2.200). Trying to connect to non-existing API version (I'm aware that v2 is not yet available on LIVE environment yet)

    val apiKey = "API_KEY"
    val apiSecret = "API_SECRET"
    val client = FiskalyHttpClient(apiKey, apiSecret, "https://kassensichv.io/api/v2") // <- v2 is not yet deployed to live
    println(client.request("GET", "/tss"))

results in native sdk crash (e.g. on MacOS, it is

panic: runtime error: invalid memory address or nil pointer dereference
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1356cbda9]

goroutine 17 [running, locked to thread]:
fiskaly.com/client/methods.httpRequest(0xc0000b4780, 0xc00012c300, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    fiskaly.com/client/methods/request.go:276 +0x372
fiskaly.com/client/methods.RequestHandler(0xc00013e500, 0x247, 0x280, 0x0, 0x0, 0x0, 0x0)
    fiskaly.com/client/methods/request.go:157 +0x773
fiskaly.com/client/jsonrpc.Invoke(0xc000136580, 0x2a1, 0x2a1, 0xc000129e90)
    fiskaly.com/client/jsonrpc/invoke.go:38 +0x176
main._fiskaly_client_invoke(0x7f9213037710, 0x0)
    fiskaly.com/client/cmd/client/main.go:17 +0x43
main._cgoexpwrap_d4e42be6ae88__fiskaly_client_invoke(0x7f9213037710, 0x0)
    _cgo_gotypes.go:84 +0x60

while on Android

com.example.fiskaly E/Go: panic: runtime error: invalid memory address or nil pointer dereference
com.example.fiskaly E/Go:   panic: runtime error: invalid memory address or nil pointer dereference
com.example.fiskaly E/Go: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x927215f8]
com.example.fiskaly E/Go: goroutine 17 [running, locked to thread]:
com.example.fiskaly E/Go: fiskaly.com/client/methods.httpRequest(0x4f980150, 0x4f98c5a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
com.example.fiskaly E/Go:   fiskaly.com/client/methods/request.go:276 +0x22c
com.example.fiskaly E/Go: fiskaly.com/client/methods.RequestHandler(0x4f9ca480, 0x21b, 0x240, 0x0, 0x0, 0x0, 0x0)
com.example.fiskaly E/Go:   fiskaly.com/client/methods/request.go:157 +0x5f0
com.example.fiskaly E/Go: fiskaly.com/client/jsonrpc.Invoke(0x4f9c8280, 0x275, 0x275, 0x4f848040)
com.example.fiskaly E/Go:   fiskaly.com/client/jsonrpc/invoke.go:38 +0x104
com.example.fiskaly E/Go: main._fiskaly_client_invoke(0x9f6aee00, 0x926b0001)
com.example.fiskaly E/Go:   fiskaly.com/client/cmd/client/main.go:17 +0x30    
    --------- beginning of crash
com.example.fiskaly A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 18878 (roidJUnitRunner)
? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
? A/DEBUG: Build fingerprint: 'PAX/msm8909/msm8909:7.1.2/N2G47H/163:user/release-keys'
? A/DEBUG: Revision: '0'
? A/DEBUG: ABI: 'arm'
? A/DEBUG: pid: 18862, tid: 18878, name: roidJUnitRunner  >>> com.example.fiskaly <<<
? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
? A/DEBUG:     r0 00000000  r1 000049be  r2 00000006  r3 00000008
? A/DEBUG:     r4 000049ae  r5 00000000  r6 00000002  r7 0000010c
? A/DEBUG:     r8 00000007  r9 00000002  sl 4f800380  fp 92c886f0
? A/DEBUG:     ip 00000004  sp 4f88189c  lr 92705f34  pc 92723d70  cpsr 600f0010
? A/DEBUG: backtrace:
? A/DEBUG:     #00 pc 000eed70  /data/app/com.example.fiskaly-1/base.apk (offset 0x33000)

)

Shouldn't such a case be somehow handled, e.g. some error instead of crash?