Skip to content

Commit a6a137d

Browse files
authored
chore: improve error message when asset wasm is not allowlisted in playground (#4035)
1 parent 4722c29 commit a6a137d

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
This used to be a warning. A hard error can abort the command so that no insecure state will be on the mainnet.
1212

13-
Users can surpress this error by setting `export DFX_WARNING=-mainnet_plaintext_identity`.
13+
Users can suppress this error by setting `export DFX_WARNING=-mainnet_plaintext_identity`.
1414

1515
The warning won't display when executing commands like `dfx deploy --playground`.
1616

@@ -48,6 +48,9 @@ Please top up your cycles balance by converting ICP to cycles like below:
4848
'dfx cycles convert --amount=0.123'.
4949
```
5050

51+
If users run `dfx deploy --playground` but the backend is not updated with the latest frontend canister wasm
52+
the error message will explain this properly and recommends asking for help on the forum since this can't be resolved by users.
53+
5154
### chore: improve `dfx cycles convert` messages.
5255

5356
If users run `dfx cycles convert` without enough ICP tokens, show additional messages to indicate what to do next.

src/dfx/src/lib/operations/canister/motoko_playground.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
use crate::lib::diagnosis::DiagnosedError;
12
use crate::lib::{environment::Environment, error::DfxResult};
2-
use anyhow::{bail, Context};
3+
use anyhow::{anyhow, bail, Context};
34
use candid::{encode_args, CandidType, Decode, Deserialize, Encode, Principal};
45
use dfx_core::config::model::canister_id_store::AcquisitionDateTime;
56
use dfx_core::config::model::network_descriptor::{
@@ -210,7 +211,16 @@ pub async fn playground_install_code(
210211
.update(&playground_canister, "installCode")
211212
.with_arg(encoded_arg.as_slice())
212213
.await
213-
.context("install failed")?;
214+
.map_err(|err| {
215+
if is_asset_canister && err.to_string().contains("Wasm is not whitelisted") {
216+
anyhow!(DiagnosedError {
217+
error_explanation: Some("The frontend canister wasm needs to be allowlisted in the playground but it isn't. This is a mistake in the release process.".to_string()),
218+
action_suggestion: Some("Please report this on forum.dfinity.org and mention your dfx version. You can get the version with 'dfx --version'.".to_string()),
219+
})
220+
} else {
221+
anyhow!(err)
222+
}
223+
})?;
214224
let out = Decode!(&result, CanisterInfo)?;
215225
out.get_timestamp()
216226
}

0 commit comments

Comments
 (0)