square / square/in-app-payments-react-native-plugin

Android crashes during service incident

Open
#242 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
131
Forks
55
PR merge metrics
No merged PRs in 30d

Description

Describe the issue

Between 12 June 2024 and 16 June 2024 during service incident, Android crashes at Card Entry screen after press 'Save' button. iOS shows 'unexpected error' alert.
Exception:

Your app just crashed. See the error below.
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
  com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:502)
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)

Caused by java.lang.reflect.InvocationTargetException
  java.lang.reflect.Method.invoke(Native Method)
  com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)

Caused by com.squareup.moshi.JsonEncodingException: Use JsonReader.setLenient(true) to accept malformed JSON at path $
  com.squareup.moshi.JsonReader.syntaxError(JsonReader.java:243)
  com.squareup.moshi.JsonUtf8Reader.checkLenient(JsonUtf8Reader.java:1152)
  com.squareup.moshi.JsonUtf8Reader.doPeek(JsonUtf8Reader.java:384)
  com.squareup.moshi.JsonUtf8Reader.peek(JsonUtf8Reader.java:206)
  com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:38)
  com.squareup.moshi.JsonAdapter.fromJson(JsonAdapter.java:58)
  sqip.internal.nonce.RealCreateCardNonceRequestHandler.onResponse(RealCreateCardNonceRequestHandler.kt:132)
  sqip.internal.nonce.RealCreateCardNonceRequestHandler$sendRequest$1.onResponse(RealCreateCardNonceRequestHandler.kt:56)
  retrofit2.DefaultCallAdapterFactory$ExecutorCallbackCall$1.lambda$onResponse$0$retrofit2-DefaultCallAdapterFactory$ExecutorCallbackCall$1(DefaultCallAdapterFactory.java:82)
  retrofit2.DefaultCallAdapterFactory$ExecutorCallbackCall$1$$ExternalSyntheticLambda0.run(Unknown Source:6)
  android.os.Handler.handleCallback(Handler.java:883)
  android.os.Handler.dispatchMessage(Handler.java:100)
  android.os.Looper.loop(Looper.java:214)
  android.app.ActivityThread.main(ActivityThread.java:7397)
  java.lang.reflect.Method.invoke(Native Method)
  com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
To Reproduce

Today (17 June 2024) it's impossible to reproduce as services are working fine.

Expected behavior

Android should not crash if services are not working on at maintenance.

Environment (please complete the following information):

  • Platform: Android
  • OS: any
  • dev environment: MacOS
  • In-App Payments Plugin version: 1.7.6
System:
  OS: macOS 14.5
  CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Memory: 497.12 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.20.2
    path: ~/.nvm/versions/node/v18.20.2/bin/node
  Yarn:
    version: 1.22.15
    path: ~/.nvm/versions/node/v18.20.2/bin/yarn
  npm:
    version: 10.5.0
    path: ~/.nvm/versions/node/v18.20.2/bin/npm
  Watchman:
    version: 2024.04.22.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/kowalski/.rvm/gems/ruby-2.7.4/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK:
    API Levels:
      - "29"
      - "30"
      - "31"
      - "33"
      - "34"
    Build Tools:
      - 28.0.3
      - 29.0.3
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.2
      - 34.0.0
    System Images:
      - android-30 | Google Play Intel x86 Atom
      - android-31 | Google Play Intel x86_64 Atom
      - android-33 | Google APIs Intel x86_64 Atom
    Android NDK: 23.0.7123448-beta1
IDEs:
  Android Studio: 2024.1 AI-241.15989.150.2411.11948838
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home/bin/javac
  Ruby:
    version: 2.7.4
    path: /Users/kowalski/.rvm/rubies/ruby-2.7.4/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.2
    wanted: 0.74.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
Screenshots

No Screenshots

Additional context

I think the reason of crash is html which can't be parsed by moshi in native part of library. I didn't have time to check traffic between server and app to catch the real response of Square in app payments service

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the stack trace entry point in sqip/internal/nonce/RealCreateCardNonceRequestHandler.kt, especially line 132, and inspect how the service response is handled after Save. Confirm the malformed response scenario if possible; done means the Android Card Entry flow reports a service failure without crashing.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin, react-native, typescript
Domain
mobile, payments
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.