at_client_sdk
at_client_sdk copied to clipboard
`AtClient.get` throws an AtClientException when it should be AtKeyNotFoundException
Describe the bug
AtClient.get
is throwing an AtClientException when it should be throwing a AtKeyNotFoundException
Steps to reproduce
- Try doing
AtClient.get
in a try/catch on apublic:publickey@
- We know that the secondary exists but the public:publickey has not been instantiated yet (since they haven't onboarded yet).
-
AtClient.get
throws an AtClientException
See logs in additional context section.
Expected behavior
AtClient.get
throws a AtKeyNotFoundException when the public:publickey@
does not exist.
Screenshots
No response
Smartphones
No response
Were you using an atApplication when the bug was found?
No response
Additional context
The dart code I ran:
```dart
try {
await atClient.get(publicKey);
return true;
} catch (e) {
if(e is AtKeyNotFoundException || e is AtClientException) {
return false;
}
rethrow;
}
The error message
AtClientException // the exception that it threw, I used print()
Unhandled exception:
Exception: Internal server exception : Request to remote secondary @noblesnowbaboon at null:null received error response 'AT0015-Exception: public:publickey@noblesnowbaboon does not exist in keystore'
#0 AtClientImpl.get (package:at_client/src/client/at_client_impl.dart:349)
<asynchronous suspension>
#1 atSignIsActivated (package:sshnoports/sshnp_utils.dart:84)
<asynchronous suspension>
#2 SSHNP.init (package:sshnoports/sshnp.dart:180)
<asynchronous suspension>
#3 main (file:///build/repo/bin/sshnp.dart:21)
<asynchronous suspension>
@JeremyTubongbanua how does an atsign have a secondary without being onboarded? not sure how to tackle this.
Three stages:
- Registration - atSign is registered but not activated - no atServer running
- Activation - atServer running
- Onboarding - user does cram auth, generates atKeys
Ooo, thanks Gary. I didn't know that activation and onboarding were different. That would make sense.
@Xlin123 to expand on Gary's comment
- Registration - you bought the atSign and it's assigned to your email
- Activation - you clicked the orange "Activate" button on your dashboard of atSigns
- Onboarding
- Authenticate - subsequent authentications to your atServer using PKAM
Regarding this ticket, 1. Registration and 2. Activation has occurred, but 3. Onboarding has not yet occurred.
I've been doing some digging, and I think the bug is coming from at_lookup. It's a big chain of different error codes, we've got
- "AT0015" - AtKeyNotFound thrown from at_lookup
- "AT0011" - InternalServerException thrown from at_lookup
- "AT0014" - AtClientException throw from at_client
The exceptions being thrown technically aren't incorrect? Would it be okay to leave these as is?
Anyway, I tested out my theory of it being an issue with at_lookup and got this back.
Thoughts on how to proceed?
@xavierchanth@plookup:public:publickey@xavierchanth
error:AT0011-Internal server exception : Request to remote secondary @xavierchanth at null:null received error response 'AT0015-Exception: public:public:publickey@xavierchanth does not exist in keystore'
@xavierchanth@plookup:publickey@xavierchanth
data:<res>
@xavierchanth@
When doing plookup you must not include public:
It should be plookup:publickey@alice not plookup:public:publickey@alice
We really need to change the verb handlers to either be more forgiving of requests like this, or more discerning in request validation
When doing plookup you must not include public:
It should be plookup:publickey@alice not plookup:public:publickey@alice
Yeah noted in my example code, we were trying to chase down Jeremy's issue and we think that it is because plookup:public:publickey@alice
is getting executed...
Oops my bad, I never realized that... but judging by jeremy's error, AtClient.get handles public keys properly (unlike how I handled them).
Regardless, the issue is really inside of at_lookup, the RemoteSecondary does handle KeyNotFoundExceptions properly but at_lookup is changing the error code to something different. (Specifically to AT0011, InternalServerException)
@murali-shris do you want me to finish this or did you want to take it over?
I haven't touched it in almost a year.
@murali-shris do you want me to finish this or did you want to take it over?
I haven't touched it in almost a year.
@Xlin123 I will investigate this issue in the current sprint