Skip to content

Commit

Permalink
Merge branch 'ielashi/error_message' into 'master'
Browse files Browse the repository at this point in the history
chore: make payload exceeded error message more readable

When a canister creates a request that exceeds the payload, the error message currently:
1. Displays both the local subnet limit and the remote subnet limit, even though only the local subnet limit is relevant.
2. Doesn't display the payload size.

This change addresses both of the above faults. 

See merge request dfinity-lab/public/ic!13664
  • Loading branch information
ielashi committed Jul 19, 2023
2 parents b790677 + 26fe0dd commit da3667c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions rs/system_api/src/request_in_prep.rs
Expand Up @@ -67,8 +67,8 @@ impl RequestInPrep {
let max_size_local_subnet = max_size_remote_subnet * multiplier_max_size_local_subnet;
if method_name_len as u64 > max_size_local_subnet.get() {
return Err(HypervisorError::ContractViolation(format!(
"RequestInPrep: size of method_name {} exceeded the allowed limit local-subnet {} remote-subnet {}",
callee_size, max_size_local_subnet, max_size_remote_subnet
"Size of method_name {} exceeds the allowed limit local-subnet {}",
callee_size, max_size_local_subnet
)));
}
let method_name = valid_subslice(
Expand Down Expand Up @@ -126,8 +126,11 @@ impl RequestInPrep {
self.max_size_remote_subnet * self.multiplier_max_size_local_subnet;
if size as u64 > max_size_local_subnet.get() - current_size as u64 {
Err(HypervisorError::ContractViolation(format!(
"RequestInPrep: current_size {} exceeded the allowed limit local-subnet {} remote-subnet {}",
current_size, max_size_local_subnet, self.max_size_remote_subnet
"Request to {}:{} has a payload size of {}, which exceeds the allowed local-subnet limit of {}",
self.callee,
self.method_name,
current_size + size as usize,
max_size_local_subnet
)))
} else {
let data = valid_subslice("ic0.call_data_append", src, size, heap)?;
Expand Down Expand Up @@ -174,7 +177,9 @@ pub(crate) fn into_request(
let max_size_local_subnet = max_size_remote_subnet * multiplier_max_size_local_subnet;
if payload_size > max_size_local_subnet.get() {
return Err(HypervisorError::ContractViolation(format!(
"RequestInPrep: size of message {} exceeded the allowed remote-subnet limit {}",
"Request to {}:{} has a payload size of {}, which exceeds the allowed remote-subnet limit of {}",
destination_canister,
method_name,
payload_size, max_size_remote_subnet
)));
}
Expand Down

0 comments on commit da3667c

Please sign in to comment.