-
Notifications
You must be signed in to change notification settings - Fork 601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@aws-sdk/client-lightsail throws the base exception instead of a specific exception #6606
Comments
Hi @omid-sadeghi , Thanks for reaching out. The error you are seeing is a modeled error coming from the service. The SDK team cannot change this service side behavior.
I'm not sure I understand how Additionally, after probing the API and logging the actual error message alongside with the error code, I can see the Lightsail uses
Changing the resource name to fit the validation rules to soemthing like: "nonExistentInstance_123", will result in the same exception but a different error message:
Lastly, while this does seem like a documentation discrepancy where the service documents one thing, but returns another, it's possible that we are overlooking some combination of inputs where that exception is actually thrown. Unfortunately I do not have access to the server code to check for the error handling logic to give you a conclusive answer. If there is anything else I can do to help, pleaes let me know. |
This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing. |
Hi @RanVaknin So you say the issue is related to the service and you cannot do anything. Where can I possibly report the issue to so they can consider this? You said:
I specifically point to a blog post in aws which says instead of using the Because every exception is |
Hi @omid-sadeghi ,
You can use the AWS console to open a support ticket and ask for it to be routed to the Lightsail service team.
Ah yes, I agree with this sentiment, the error returned is not very useful, but you can still use instanceof on I'm going to transfer this to the cross SDK repository since this is not an SDK specific problem. Feel free to mention my internal AWS alias Thank you for the clarification. Keep us posted. |
Thank you @RanVaknin Unfortunately In my AWS console I have Basic Support plan which excludes technical support and I cannot open a ticket for this case. By the way, I used workarounds to do my job but if this exception thing is corrected, we can write a better code. I hope this problem is solved. |
Hey there, Just got back from service team - Please refer https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetInstance.html#API_GetInstance_Errors The service team indicates that you need to be checking for InvalidInputException in addition to NotFoundException. Since the provided input name is invalid, the request is failing with that type of error rather than the type not-found. Also I will try to execute and repro later to confirm, but the below should be code fix they need to make -> import { LightsailClient, GetInstanceCommand, GetStaticIpCommand, NotFoundException, InvalidInputException, LightsailServiceException} from "@aws-sdk/client-lightsail";
const client = new LightsailClient({});
try{
await client.send(new GetInstanceCommand({instanceName: "non-existent instance"}));
}
catch(e){
if(e instanceof NotFoundException)
console.log("NotFoundException")
else if(e instanceof InvalidInputException) //FIX NEEDED IN REPORTER's CODE
console.log("InvalidInputException")
else if(e instanceof LightsailServiceException)
console.log("LightsailServiceException");
} There is no service issue neither in code nor documentation. Closing this ticket. Thanks! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Checkboxes for prior research
Describe the bug
In lightsail-client, when
GetStaticIpCommand
andGetInstanceCommand
don't find the resource, they throwLightsailServiceException
but according to the docs for GetStaticIpCommand and GetInstanceCommand, they should throwNotFoundException
and the current behaviour makesinstanceof
useless for checking type of the exception at runtime becauseLightsailServiceException
is the base exception. Unfortunately, I must resort to checking by the thename
property.SDK version number
@aws-sdk/[email protected]
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v20.9.0
Reproduction Steps
Observed Behavior
The code outputs:
LightsailServiceException
LightsailServiceException
Expected Behavior
I expect to see:
NotFoundException
NotFoundException
Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: