binchoo / PaimonGanyu

여행 비서 페이몬! Genshin Impact AWS workflows & KakaoTalk chatbot skills
https://pf.kakao.com/_mtPFb
GNU General Public License v3.0
7 stars 1 forks source link

[Hoyopass][Infra][HoyoApi] HoyolabAccountWebClient sometimes gets user roles of Honkai Impact #11

Closed binchoo closed 2 years ago

binchoo commented 2 years ago

As-is: The API sometimes returns 'KR01` region. It is a server region of the Honkai Impact. (Honkai Impact Server List)

template=org.binchoo.paimonganyu.ikakao.type.SkillTemplate@3868ef88, context=null, data=null)}
Jun 27 12:46:59 ip-172-31-9-230 web: 2022-06-27 12:46:59.814 DEBUG 23918 --- [nio-5000-exec-9] o.b.p.c.c.ExceptionExplainAdvice         : An error handled by default method:
Jun 27 12:46:59 ip-172-31-9-230 web: java.lang.IllegalArgumentException: No enum constant org.binchoo.paimonganyu.hoyopass.Region.KR01
Jun 27 12:46:59 ip-172-31-9-230 web: at java.base/java.lang.Enum.valueOf(Enum.java:240) ~[na:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at org.binchoo.paimonganyu.hoyopass.Region.valueOf(Region.java:3) ~[domain-1.0.0.jar!/:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at org.binchoo.paimonganyu.hoyopass.Region.fromString(Region.java:28) ~[domain-1.0.0.jar!/:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at org.binchoo.paimonganyu.infra.hoyopass.web.UidSearchClientAdapter.lambda$mapUserGameRoleToUid$0(UidSearchClientAdapter.java:61) ~[classes!/:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) ~[na:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at org.binchoo.paimonganyu.infra.hoyopass.web.UidSearchClientAdapter.mapUserGameRoleToUid(UidSearchClientAdapter.java:64) ~[classes!/:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at org.binchoo.paimonganyu.infra.hoyopass.web.UidSearchClientAdapter.findUids(UidSearchClientAdapter.java:34) ~[classes!/:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at org.binchoo.paimonganyu.hoyopass.Hoyopass.fillUids(Hoyopass.java:35) ~[domain-1.0.0.jar!/:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at org.binchoo.paimonganyu.hoyopass.UserHoyopass.fillUids(UserHoyopass.java:134) ~[domain-1.0.0.jar!/:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at org.binchoo.paimonganyu.hoyopass.UserHoyopass.addIncomplete(UserHoyopass.java:87) ~[domain-1.0.0.jar!/:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at org.binchoo.paimonganyu.service.hoyopass.HoyopassRegister.registerHoyopass(HoyopassRegister.java:42) ~[domain-1.0.0.jar!/:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at org.binchoo.paimonganyu.service.hoyopass.SecureHoyopassRegister.registerHoyopass(SecureHoyopassRegister.java:35) ~[domain-1.0.0.jar!/:na]
Jun 27 12:46:59 ip-172-31-9-230 web: at org.binchoo.paimonganyu.chatbot.controllers.HoyopassController.addHoyopass(HoyopassController.java:34) ~[classes!/:na]

To-be: HoyolabAccountWebClient.getUserGameRoles must effectively request the user roles of Genshin Impact, not of Honkai Impact.

binchoo commented 2 years ago

This is due to the single API endpoint that can fetch both Genshin and Honkai Impact's user data simultaneously...

binchoo commented 2 years ago

Added a filter logic that filter outs all honkai impact UserGameRoles.

binchoo commented 2 years ago

The API with troubles: https://api-account-os.hoyolab.com/binding/api/getUserGameRolesByLtoken

UserGameRole response differs per game_biz value

But my webclient is already explicitly using game_biz=hk4e_global parameter...

binchoo commented 2 years ago

I made a mistake!

https://github.com/binchoo/PaimonGanyu/blob/a8451b2af0500a654e7e467f43d1c296d9483646/PaimonGanyu/hoyoapi/src/main/java/org/binchoo/paimonganyu/hoyoapi/webclient/HoyolabAccountWebClient.java#L27-L32

Line 30 is not setting the query parameter of the URI!!! It is assigning a value to a URI variable {game_biz}. How stupid.