Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
fix(daemon): make id mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
juligasa committed May 17, 2024
1 parent 7c852b9 commit d4d0794
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
8 changes: 7 additions & 1 deletion backend/daemon/api/documents/v1alpha/documents.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,10 @@ func (api *Server) MergeChanges(ctx context.Context, in *documents.MergeChangesR
return nil, fmt.Errorf("At least two versions are necessary for merging")
}

if in.Id == "" {
return nil, fmt.Errorf("Document Id is a mandatory field")
}

allHeads := []cid.Cid{}
for _, version := range in.Versions {
heads, err := hyper.Version(version).Parse()
Expand All @@ -971,9 +975,11 @@ func (api *Server) MergeChanges(ctx context.Context, in *documents.MergeChangesR
if err != nil {
return nil, err
}

if entity == nil {
return nil, fmt.Errorf("void entity after applying all versions")
return nil, fmt.Errorf("Error merging. Are all the versions coming from the same document?")
}

del, err := api.getDelegation(ctx)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions backend/genproto/documents/v1alpha/documents.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -875,14 +875,14 @@ export class ListAccountPublicationsRequest extends Message<ListAccountPublicati
*/
export class MergeChangesRequest extends Message<MergeChangesRequest> {
/**
* Document ID of the resulting document.
* Required. Document ID from which versions are going to be taken.
*
* @generated from field: string id = 1;
*/
id = "";

/**
* Required. Versions to be merged into the document ID provided.
* Required. Versions to be merged.
*
* @generated from field: repeated string versions = 2;
*/
Expand Down
4 changes: 2 additions & 2 deletions proto/documents/v1alpha/documents.proto
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ service Merge {

// Request for merging changes in a document.
message MergeChangesRequest {
// Document ID of the resulting document.
// Required. Document ID from which versions are going to be taken.
string id = 1;

// Required. Versions to be merged into the document ID provided.
// Required. Versions to be merged.
repeated string versions = 2;
}

Expand Down
4 changes: 2 additions & 2 deletions proto/documents/v1alpha/go.gensum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
srcs: 08d35261ed63c55189dc8f77a350ddbe
outs: 5f5b631a6f2394e141faaaf1ca01b759
srcs: 634ff8c56155cd59d4dd78d3d6992cc1
outs: 64189a6f9d0757ec00633bfedb683d55
4 changes: 2 additions & 2 deletions proto/documents/v1alpha/js.gensum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
srcs: 08d35261ed63c55189dc8f77a350ddbe
outs: c1ca57f177ed97af902ce3f5639662f8
srcs: 634ff8c56155cd59d4dd78d3d6992cc1
outs: 282e9eafe19cffcafa7ee15c32fee33c

0 comments on commit d4d0794

Please sign in to comment.