Skip to content
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

feat(rover-client): improves error handling #209

Merged
merged 1 commit into from
Jan 29, 2021

Conversation

EverlastingBugstopper
Copy link
Contributor

Adds some more strongly typed errors in rover-client
in addition to some new suggestions in rover.

@EverlastingBugstopper EverlastingBugstopper added feature 🎉 new commands, flags, functionality, and improved error messages status - needs review labels Jan 28, 2021
@EverlastingBugstopper EverlastingBugstopper added this to the 🐣 0.1.0 milestone Jan 28, 2021
@EverlastingBugstopper EverlastingBugstopper force-pushed the avery/my-number-one-client branch 2 times, most recently from 0116589 to 101ae48 Compare January 28, 2021 21:47
@EverlastingBugstopper EverlastingBugstopper force-pushed the avery/my-number-one-client branch 2 times, most recently from 5b58b98 to 2d908cd Compare January 29, 2021 16:15
Comment on lines 37 to 54
fn get_push_response_from_data(
data: push_schema_mutation::ResponseData,
graph: String,
) -> Result<push_schema_mutation::PushSchemaMutationServiceUploadSchema, RoverClientError> {
// then, from the response data, get .service?.upload_schema?
let service_data = match data.service {
Some(data) => data,
None => return Err(RoverClientError::NoService),
None => return Err(RoverClientError::NoService { graph }),
};

if let Some(opt_data) = service_data.upload_schema {
Ok(opt_data)
} else {
Err(RoverClientError::HandleResponse {
msg: "No response from mutation. Check your API key & graph name".to_string(),
Err(RoverClientError::AdhocError {
msg: "No response from the graph registry. Check your API key & graph name".to_string(),
})
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RoverClientError::NoService typically implies that either the API key is invalid, or the graph does not exist - so what's the deal if upload_schema is null? - I think since we already know that data.service is not null, then the API key AND the graph name should both be valid, meaning the error message we have here is not correct. Is this a malformed response? Why does the API allow this field to return null? What does it signify? These numbers Mason, what do they mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/mdg-private/monorepo/blob/abca4af89d0a84ee51add654db3362374e5ba2fa/registry/src/resolvers/ServiceMutation.ts#L1019-L1037
Looking at the resolver that runs this code, it looks like the null value here would mean that the operation on the backend to actually store the schema failed. There's a vaild graph and variant, but something went wrong with the actual storage operation of the schema. I feel like this could've been rolled into the success and message here instead of making this nullable but that's where we're at

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Can we then say exactly what you just wrote: 'Apollo Studio wasn't able to store the schema`?

Copy link
Contributor Author

@EverlastingBugstopper EverlastingBugstopper Jan 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added null_field to MalformedResponse since it seems like this would be a bug that the user can't fix. Do we think that's OK here or should we make this a typed error and then have the suggestion be "rerun this command and submit an issue if it keeps happening?"

i think for now we should keep it as MalformedResponse and then if it happens frequently we'll get people reporting issues that we can then escalate

@EverlastingBugstopper EverlastingBugstopper force-pushed the avery/my-number-one-client branch 2 times, most recently from 512dc87 to 74e67db Compare January 29, 2021 16:35
Err(RoverClientError::HandleResponse {
msg: "No response from mutation. Check your API key & graph name".to_string(),
})
Err(RoverClientError::MalformedResponse)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Err(RoverClientError::MalformedResponse)
Err(RoverClientError::AdhocError {
msg: "Apollo Studio failed to store the schema".to_string()
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added null_field to MalformedResponse so when we tell folks to submit an issue they can tell us what field was null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really hoping these MalformedResponse errors just.. never occur! but since they can be null, they likely will. I'd like to treat those as bugs though, so if we get an issue where folks are getting this, we need to either handle the error better or fix it in the API

Adds some more strongly typed errors in rover-client
in addition to some new suggestions in rover.
@EverlastingBugstopper EverlastingBugstopper merged commit 7cc52b3 into main Jan 29, 2021
@EverlastingBugstopper EverlastingBugstopper deleted the avery/my-number-one-client branch January 29, 2021 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🎉 new commands, flags, functionality, and improved error messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants