diff --git a/code/go/0chain.net/blobbercore/handler/file_command_delete.go b/code/go/0chain.net/blobbercore/handler/file_command_delete.go index 38497b283..8c9a3eb10 100644 --- a/code/go/0chain.net/blobbercore/handler/file_command_delete.go +++ b/code/go/0chain.net/blobbercore/handler/file_command_delete.go @@ -3,6 +3,7 @@ package handler import ( "context" "errors" + "fmt" "net/http" "github.com/0chain/gosdk/constants" @@ -33,7 +34,7 @@ func (cmd *DeleteFileCommand) GetPath() string { // IsValidated validate request. func (cmd *DeleteFileCommand) IsValidated(ctx context.Context, req *http.Request, allocationObj *allocation.Allocation, clientID string) error { if allocationObj.OwnerID != clientID && allocationObj.RepairerID != clientID { - return common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } path, ok := common.GetField(req, "path") diff --git a/code/go/0chain.net/blobbercore/handler/file_command_update.go b/code/go/0chain.net/blobbercore/handler/file_command_update.go index 1b1daf5d4..684324cc4 100644 --- a/code/go/0chain.net/blobbercore/handler/file_command_update.go +++ b/code/go/0chain.net/blobbercore/handler/file_command_update.go @@ -47,7 +47,7 @@ func (cmd *UpdateFileCommand) GetPath() string { // IsValidated validate request. func (cmd *UpdateFileCommand) IsValidated(ctx context.Context, req *http.Request, allocationObj *allocation.Allocation, clientID string) error { if allocationObj.OwnerID != clientID && allocationObj.RepairerID != clientID { - return common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } uploadMetaString := req.FormValue(UploadMeta) @@ -171,7 +171,7 @@ func (cmd *UpdateFileCommand) ProcessContent(ctx context.Context, allocationObj } if allocationObj.BlobberSizeUsed+allocationSize > allocationObj.BlobberSize { - return result, common.NewError("max_allocation_size", "Max size reached for the allocation with this blobber") + return result, common.NewError("max_allocation_size", fmt.Sprintf("Max size reached for the allocation with this blobber : %d < %d", allocationObj.BlobberSize, allocationObj.BlobberSizeUsed+allocationSize)) } return result, nil diff --git a/code/go/0chain.net/blobbercore/handler/file_command_upload.go b/code/go/0chain.net/blobbercore/handler/file_command_upload.go index 88fea77f9..e2eaa641f 100644 --- a/code/go/0chain.net/blobbercore/handler/file_command_upload.go +++ b/code/go/0chain.net/blobbercore/handler/file_command_upload.go @@ -53,7 +53,7 @@ func (cmd *UploadFileCommand) GetPath() string { // IsValidated validate request. func (cmd *UploadFileCommand) IsValidated(ctx context.Context, req *http.Request, allocationObj *allocation.Allocation, clientID string) error { if allocationObj.OwnerID != clientID && allocationObj.RepairerID != clientID { - return common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } fileChanger := &allocation.UploadFileChanger{} @@ -187,7 +187,7 @@ func (cmd *UploadFileCommand) ProcessContent(ctx context.Context, allocationObj } if allocationObj.BlobberSizeUsed+allocationSize > allocationObj.BlobberSize { - return result, common.NewError("max_allocation_size", "Max size reached for the allocation with this blobber") + return result, common.NewError("max_allocation_size", fmt.Sprintf("Max size reached for the allocation with this blobber : %d < %d", allocationObj.BlobberSize, allocationObj.BlobberSizeUsed+allocationSize)) } return result, nil diff --git a/code/go/0chain.net/blobbercore/handler/object_operation_handler.go b/code/go/0chain.net/blobbercore/handler/object_operation_handler.go index 968eaa2a1..46be1c1fc 100644 --- a/code/go/0chain.net/blobbercore/handler/object_operation_handler.go +++ b/code/go/0chain.net/blobbercore/handler/object_operation_handler.go @@ -558,7 +558,7 @@ func (fsh *StorageHandler) CreateConnection(ctx context.Context, r *http.Request } if allocationObj.OwnerID != clientID && allocationObj.RepairerID != clientID { - return nil, common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return nil, common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } valid, err := verifySignatureFromRequest(allocationTx, r.Header.Get(common.ClientSignatureHeader), r.Header.Get(common.ClientSignatureHeaderV2), allocationObj.OwnerPublicKey) @@ -756,7 +756,7 @@ func (fsh *StorageHandler) CommitWrite(ctx context.Context, r *http.Request) (*b if allocationObj.BlobberSizeUsed+connectionObj.Size > allocationObj.BlobberSize { return nil, common.NewError("max_allocation_size", - "Max size reached for the allocation with this blobber") + fmt.Sprintf("Max size reached for the allocation with this blobber : %d < %d", allocationObj.BlobberSize, allocationObj.BlobberSizeUsed+connectionObj.Size)) } if latestWriteMarkerEntity != nil && latestWriteMarkerEntity.WM.ChainSize+connectionObj.Size != writeMarker.ChainSize { @@ -1245,7 +1245,7 @@ func (fsh *StorageHandler) CreateDir(ctx context.Context, r *http.Request) (*all allocationID := allocationObj.ID if clientID == "" { - return nil, common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return nil, common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } dirPath := r.FormValue("dir_path") @@ -1288,7 +1288,7 @@ func (fsh *StorageHandler) CreateDir(ctx context.Context, r *http.Request) (*all } if clientID != allocationObj.OwnerID { - return nil, common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return nil, common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } if err := validateParentPathType(ctx, allocationID, dirPath); err != nil { @@ -1341,7 +1341,7 @@ func (fsh *StorageHandler) WriteFile(ctx context.Context, r *http.Request) (*all return nil, common.NewError("invalid_parameters", "Invalid connection id passed") } if clientID == "" { - return nil, common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return nil, common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationID, clientID)) } if ok := CheckBlacklist(clientID); ok { return nil, common.NewError("blacklisted_client", "Client is blacklisted: "+clientID) @@ -1361,7 +1361,7 @@ func (fsh *StorageHandler) WriteFile(ctx context.Context, r *http.Request) (*all } if allocationObj.OwnerID != clientID && allocationObj.RepairerID != clientID { - return nil, common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation") + return nil, common.NewError("invalid_operation", fmt.Sprintf("Operation needs to be performed by the owner or the payer of the allocation %s : client %s", allocationObj.ID, clientID)) } elapsedAllocation := time.Since(st)