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

Add error details for Upload and GetCommits #129

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

oliversun9
Copy link
Contributor

This adds error details for Upload and GetCommits. This change allows servers (at least the BSR) to return structured errors when multiple commit IDs or resource refs are not found (could be extended later to account for other types of errors).

Copy link

github-actions bot commented Aug 2, 2024

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedAug 12, 2024, 5:53 PM

message GetCommitsErrorDetails {
// This contains the resource_refs that the server is unable to find. This is populated
// when a non-found error is returned by the server.
repeated ResourceRef not_found_resource_refs = 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ResourceRef is request_only, should we expand request_only to allow error details?

Comment on lines +87 to +92
// UploadErrorDetails is the error details for the Upload RPC.
message UploadErrorDetails {
// This contains the dep_commit_ids that the server is unable to find. This is populated
// when a non-found error is returned by the server.
repeated string not_found_dep_commit_ids = 1;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have much experience with error details, but I'm wondering if we should structure these RPC-specific error details a little more like a "giant oneof". Something like this:

message UploadErrorDetails {
  message ModuleNotFoundErrorDetail {
    ModuleRef module_ref = 1;
    int32 content_index = 2;
  }
  message DepCommitNotFoundErrorDetail {
    string commit_id = 1;
  }
  message CycleDetectedErrorDetail {
    repeated string commit_ids = 1;
  }
  message UnknownFileTypeErrorDetail {
    int32 content_index = 1;
    string file_path = 2;
  }
  oneof value {
    ModuleNotFoundErrorDetail module_not_found = 1;
    DepCommitNotFoundErrorDetail dep_commit_not_found = 2;
    CycleDetectedErrorDetail cycle_detected = 3;
    UnknownFileTypeErrorDetail unknown_file_type = 4;
  }
}

This would enable clients to handle cases of errors instead of conditionally checking if a field/set of fields are set to determine the semantics of the error. It's also very obvious what kinds of structured errors this RPC could return.

In the future, we could also define common error details that can compose nicely with this pattern, but that gets into plurality/etc. that we don't need to consider for now... just thinking out loud here.

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 think using oneof is definitely nice. However, will there ever be a need to return both ModuleNotFound and DepCommitNotFound? If so, I think the oneof could be categorized by error code instead.

As an example of a common error detail, we could also add buf.validate.Violations to the oneof in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants