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

init doesn’t handle download errors correctly #7122

Closed
mina86 opened this issue Jun 27, 2022 · 1 comment
Closed

init doesn’t handle download errors correctly #7122

mina86 opened this issue Jun 27, 2022 · 1 comment
Assignees

Comments

@mina86
Copy link
Contributor

mina86 commented Jun 27, 2022

#7121 shows that download errors (403 in that case) are not handled correctly and init continues even though the file wasn’t downloaded.

(One more reason to do second point from #6416 (comment) ?)

@andrei-near
Copy link
Contributor

Fixed in #11456

github-merge-queue bot pushed a commit that referenced this issue Jun 3, 2024
Hyper is not opinionated enough to care about connection StatusCode.
In case of errors such as AccessDenied, return code 403, it will still
download the return body and not raise any errors (see
#7121).
status_code.is_success checks if status is within 200-299.

```
nearcore/target/debug/neard --home ".near" init --chain-id inexistent_network --download-genesis --download-config
2024-06-01T18:23:34.118646Z  INFO neard: version="trunk" build="1.36.1-671-g99a05c482" latest_protocol=67
2024-06-01T18:23:34.121032Z  INFO near: Downloading config file from: https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/inexistent_network/config.json ...
Error: Failed to initialize configs

Caused by:
    0: Failed to download the config file from https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/inexistent_network/config.json
    1: Unsuccessful HTTP connection. Return code: 403 Forbidden
```

Unit test to make sure non successful codes are handled:
```
cargo test --package nearcore --lib download_file::tests::test_file_download_bad_http_code
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.33s
warning: the following packages contain code that will be rejected by a future version of Rust: fs_extra v1.2.0, wasmparser v0.78.2
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 52`
     Running unittests src/lib.rs (target/debug/deps/nearcore-9131a198eca62608)

running 1 test
test download_file::tests::test_file_download_bad_http_code ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 24 filtered out; finished in 0.00s
```
#7122
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

No branches or pull requests

3 participants
@mina86 @andrei-near and others